object not found onload

V

vadivasbro

The onload event appears to be firing before all the content of my
window loads or something. In the stripped down example below, my
browser tells me that it cannot find the object "thisThing." What
gives?


<html>
<head>

<script type="text/javascript">
window.onload = document.getElementById("thisThing").style.background =
"red";
</script>

</head>
<body>
<div id="thisThing" style="height:40px; width:50px;
background:blue">
</div>

</body>
</html>
 
L

Lee

(e-mail address removed) said:
The onload event appears to be firing before all the content of my
window loads or something. In the stripped down example below, my
browser tells me that it cannot find the object "thisThing." What
gives?


<html>
<head>

<script type="text/javascript">
window.onload = document.getElementById("thisThing").style.background =
"red";
</script>


The onload event has nothing to do with your error.
The error is that you're invoking document.getElementById("thisThing")
in the <head> section, before the page loads.
 
2

2obvious

yeh...My bad, Dietmar.

I post on Google. Up until its fairly recent changes, a search on my
nickname ("2obvious") would skip me right to my latest post. Now,
apparently, the nickname can be toggled. When I didn't see my latest
post in a search, I assumed there was glitch and that I hadn't posted.
Bad form on my part.

Thanks for the link. Saves me the trouble of redirecting this post to
a correct answer myself.

--E.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top