gs99
Programmer
- Oct 7, 2001
- 40
Need to change objects depending on cookie values when script is first run.
Apparently the objects are not available, as seen in this test:
In html file:
<h3 id="hh1">Test color change in header</h3>
<input type="button" onclick="setColor()" value="Change color of header" />
In Javascript file:
function setColor()
{
document.getElementById("hh1").style.color="red";
}
When I click the button, it works OK - text changes to red.
But if I put this into Javascript file:
setColor();
to execute the function immediately, get "Object required" message.
Seems like a "document.read" is needed.
Apparently the objects are not available, as seen in this test:
In html file:
<h3 id="hh1">Test color change in header</h3>
<input type="button" onclick="setColor()" value="Change color of header" />
In Javascript file:
function setColor()
{
document.getElementById("hh1").style.color="red";
}
When I click the button, it works OK - text changes to red.
But if I put this into Javascript file:
setColor();
to execute the function immediately, get "Object required" message.
Seems like a "document.read" is needed.