[Javascript] Retaining values

J. Lester Novros II lester at denhaag.org
Thu Apr 14 18:25:59 CDT 2011


Tedd,

Let me chime in here again.

On 04/13/2011 06:07 PM, tedd wrote:
> But how do you insert something between the<p></p>  tags?

Using document.createTextNode like so:

    var t = document.createTextNode('here is some text');

    var p = document.createElement('p');
       p.appendChild(t);

    document.getElementsById('placeholder').appendChild(p);

which will result in

    <div id="placeholder"><p>here is some text</p></div>

> And while you're at it, how do you place '\n' at the end of these
> insertions so that the resultant code aren't run-ons? I hate seeing a
> long line of code without linefeeds -- makes my head hurt. :-)

My sentiments exactly. But the point here is: you don't. I assume you come 
from a PHP background where code is indeed inserted in the page and run-ons 
abound if you're not careful to pepper your PHP code with '\n's.

However, code added to the DOM using JavaScript does not show up in the 
regular view source window. You need either the DOM Inspector 
<https://addons.mozilla.org/en-US/firefox/addon/dom-inspector-6622/> or 
Firebug's equivalent to inspect the new DOM structure and see scripted additions.

l8R lES
-- 
The key used for communication between the operators and the SIM card is very
well protected, because it protects their monetary interest. The other key is
less well protected, because it only protects your private data.
                                      SRLabs' Karsten Nohl on the SIMcard hack
http://lester.demon.nl/superm                    http://lester.demon.nl/tonka


More information about the Javascript mailing list