I am trying to change the style “left” on a div. For some reason I keep getting the error that div is null.. Can’t figure out how I screwed up..
[code=php]<script language=”JavaScript” type=”text/javascript”>
function centerIt() {
if (self.innerHeight)
{
var x = self.innerWidth;
}
else if (document.documentElement && document.documentElement.clientHeight)
{
var x = document.documentElement.clientWidth;
}
else if (document.body)
{
var x = document.body.clientWidth;
}
var w_box = x;
var w_total = (w_box – 760)/2;
var div = document.getElementById(“container”);
div.style.left = w_total +”px”;
}
centerIt();
</script>
<div id=”container” style=”width: 760px; height: 75px; background-color: #FFFFFF; position: absolute; top: 0px; left: 0px;”>
Top Menu Bar
</div>