Brett Bretterso
10-13-2005, 01:56 PM
I've done a lot with getElementById, but right now I'm at home and decided to do a little scripting. I tried to do something and it wouldn't work, and I've isolated the problem to being that getElementById just won't work. When the page calls a function in a .js file that does document.getElementById it gives an error whenever I try to touch the gotten element's attributes. If I do document.getElementById on the page it simply ignores it. It doesn't throw an error, but it also won't do what it says.
The only thing I can think of for why is that it's because the html file is on my personal computer rather than a server, which I didn't think would matter because javascript is run client side.
Does anyone have any ideas why it isn't working?
Here's my code:
<script src="javascripts/clocks.js" language="javascript"></script>
<script language="javascript">
window.onLoad = new function(){
displayDatum("oDiv1");
document.getElementById("oDiv1").innerHTML="hola";
}
</script>
</head>
<body bgcolor="#7B99E1">
<div ID="oDiv1" style="background-color:#FFFFFF ">hello</div>
</body>
I also tried window.alert(document.getElementById("oDiv1").innerHTML); and it just ignored it, where it gladly did window.alert("hola");.
Any ideas would be appreciated.
Brett Bretterson
The only thing I can think of for why is that it's because the html file is on my personal computer rather than a server, which I didn't think would matter because javascript is run client side.
Does anyone have any ideas why it isn't working?
Here's my code:
<script src="javascripts/clocks.js" language="javascript"></script>
<script language="javascript">
window.onLoad = new function(){
displayDatum("oDiv1");
document.getElementById("oDiv1").innerHTML="hola";
}
</script>
</head>
<body bgcolor="#7B99E1">
<div ID="oDiv1" style="background-color:#FFFFFF ">hello</div>
</body>
I also tried window.alert(document.getElementById("oDiv1").innerHTML); and it just ignored it, where it gladly did window.alert("hola");.
Any ideas would be appreciated.
Brett Bretterson