[thelist] Is it possible to output a JavaScript variable directly to the body content after the page has been loaded?
Tom Dell'Aringa
pixelmech at yahoo.com
Mon Jan 5 15:31:53 CST 2004
--- SED <sed at sed.is> wrote:
> So my question is: Is it possible to output a JavaScript variable
> directly to the body content after the page has been loaded?
SED,
Very possible indeed. You don't want to use document.write() because
that is going to essentially re-write your whole page. What you can
do is place the variable into a form field or even a DIV tag.
To place a value in a form field, say a text field, simply use the
correct form['formname'].elements['elementName'].value notation.
If you wanted to use innerHTML (works in modern browsers NN6+ IE5+)
you could do the following:
<div id='foo'></div>
var yourJSvar = "helloWorld";
function ShowVar()
{
var myFoo = document.getElementById("foo");
myFoo.innerHTML = yourJSvar;
}
HTH
Tom
=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life
[Those who say that I am finished, and am through, will have to run over my dead body to beat me...]
More information about the thelist
mailing list