you problem is probably that you try to access your div tag before it is actually instantiated.
there are two immediate solutions to this problem
1. Set your script below the div tag. Then it should load like it's supposed to
2. Put you execution of the script inside a window load event (this is the best way)
e.g.
-
<html>
-
<head>
-
<!-- header stuff here -->
-
<script language="javascript">
-
-
-
function windowOnLoad()
-
{
-
var divElement = document.getElementById('myDiv');
-
//do stuff with your div here
-
}
-
-
try{
-
window.attachEvent('onload',windowOnLoad); //MSIE
-
} catch(e) {
-
try{
-
window.addEventListener('load,windowOnLoad,false); //Proper browser
-
} catch(e) {
-
alert('Your browser is really old');
-
}
-
}
-
-
</script>
-
</head>
-
<body>
-
<div id="myDiv">
-
</div>
-
</body>
-
</html>
-
and a little advice: try to always acces your element with document.getElementById, this ensures better browsercompability :)