PDA

View Full Version : <DIV> content in Netscape


Rik Comery
03-25-2003, 01:54 PM
Can anyone please tell my why this code does not work in Netscape 4, unless the loadLayer function is inside the MENU1 layer.

All i am trying to do is display the DIV name MENU1, when the mouse hovers over the word HOME. However the content of the DIV Must be in a function, rather than hardcoded to the DIV.


<HTML>
<BODY>
<script>
function showLayer()
{
document.MENU1.visibility = "visible";
}
</script>

<script>
function loadLayer()
{
document.writeln ('text to display');
}
</script>

<a onMouseOver="showLayer();" href="#">Home</a>

<div id="MENU1" style="visibility: hidden; position: absolute">
<script>loadLayer()</script>
</div>
</BODY>
</HTML>

Thanks

Roy Sinclair
03-26-2003, 03:56 PM
<HTML>
<BODY onload="loadLayer();">
<script>
function showLayer()
{
document.MENU1.visibility = "visible";
}

function loadLayer()
{
var obj = document.layers['MENU1'];
obj.document.open;
alert(obj);
obj.document.writeln('text to display');
obj.document.close();
alert('It should be there now')
}
</script>

<a onMouseOver="showLayer();" href="#">Home</a>

<div id="MENU1" style="visibility: hidden; position: absolute; top: 100; left: 200;">
Original content which should be replaced.
</div>
</BODY>
</HTML>


It appears that nothing can be written to that layer until the containing document has finished loading. I also made sure the document.writeln wrote to the the correct document object and added the missing document.close call, without the close it doesn't know you're done and usually won't render the new content.

Why are you still having to develop code for this ancient dog of a browser?

Rik Comery
03-26-2003, 04:52 PM
Thanks Roy. That is great.

Why are you still having to develop code for this ancient dog of a browser?

Beats me. I am must the monkey. What the organ grinder wants, the organ grinder gets!!!