G
GfxGuy
I've seen this problem posted a million times, but I've read through
all of them and can't figure out what I'm doing wrong.
Simple example (this is the whole file, no editing):
----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
#msg {
width: 512;
z-index: 10;
background-color: #bbbbbb;
text-align: left;
}
</style>
<script type="text/javascript">
<!--
function init()
{
var obj = document.getElementById("msg");
obj.document.open();
obj.document.write("Initialized");
obj.document.close();
}
-->
</script>
</head>
<body onload="init()">
<div id="msg">Info here</div>
</body>
</html>
----------
The page displays correctly, the background of the div is gray, it
shows "Info here", but never gets changed to "Initialized". I've done
a few other things that I removed to verify that init was being called,
and called at the right time, but I've even thrown in a mouseover to
make sure that it wasn't because the document wasn't loaded, and got
the same error.
On the obj.document.open() line, I get "obj.document has no properties"
in Firefox. In IE I get a warning that the page can't be displayed
correctly... the view source in IE actually shows nothing.
What's nice is firefox can replace those three lines with just
obj.textContent="Initialized";
But IE doesn't seem to like that.
Come on, it's got to be something REALLY simple... I've tried single
quotes, double quotes, having the div section written by a
document.write...
TIA,
Fred
all of them and can't figure out what I'm doing wrong.
Simple example (this is the whole file, no editing):
----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
#msg {
width: 512;
z-index: 10;
background-color: #bbbbbb;
text-align: left;
}
</style>
<script type="text/javascript">
<!--
function init()
{
var obj = document.getElementById("msg");
obj.document.open();
obj.document.write("Initialized");
obj.document.close();
}
-->
</script>
</head>
<body onload="init()">
<div id="msg">Info here</div>
</body>
</html>
----------
The page displays correctly, the background of the div is gray, it
shows "Info here", but never gets changed to "Initialized". I've done
a few other things that I removed to verify that init was being called,
and called at the right time, but I've even thrown in a mouseover to
make sure that it wasn't because the document wasn't loaded, and got
the same error.
On the obj.document.open() line, I get "obj.document has no properties"
in Firefox. In IE I get a warning that the page can't be displayed
correctly... the view source in IE actually shows nothing.
What's nice is firefox can replace those three lines with just
obj.textContent="Initialized";
But IE doesn't seem to like that.
Come on, it's got to be something REALLY simple... I've tried single
quotes, double quotes, having the div section written by a
document.write...
TIA,
Fred