Brandon Hoppe wrote: <c1**********@home.itg.ti.com>
<snip>
Grant, please read the previous messages. What you have here isn't
the issue. Of course this works. I'm trying to update the src from
INSIDE the ilayer.
Except that what Grant is pointing out is that, for him at least,
swapping the - src - on an ILAYER is possible in addition to a LAYER. I
finally got round to looking up the Netscape 4 layer tags in that book
and I was wrong about - src - swapping only working with LAYER. What I
was wrongly remembering was the fact that you can use document.write on
a LAYER but not on an ILAYER. On the other hand I can't get grants code
to work on Netscape 4.78 on Windows or 4.77 on Linux, and the only
difference is that I was testing with local (file:// protocol) files
instead of HTTP protocol resources (that can sometimes make a big
difference).
In any event, I managed to reproduce the crashes exactly as described on
Linux Netscape 4.77. I had also noticed while looking in my book that
Netscape 4 layers have a - load - method (two arguments, a URL and a
pixel width value) that I figured might be better than setting the -
src -, but in the context of the original code it made no difference.
However, I did an experiment with having two LAYERs as children of the
ILAYER, one hidden and z-indexed under the other. And changing the
source in the hidden layer and then swapping their z-indexes and
visibility. I made two test versions, one assigning to the - src -
property and the other calling the - load - method. They both worked
better than the original, didn't crash as soon as the mouse was moved,
but repeatedly swapping the document from within itself (quite quickly)
did crash the browser. The version that used the - load - method seemed
slightly more robust in this respect:-
<html>
<head>
<script type="text/javascript">
var currentLayer = 0;
function changeLayer(url) {
var oldLayer = document.ilayerName.document['lName'+currentLayer];
currentLayer = (currentLayer+1)%2;
var newLayer = document.ilayerName.document['lName'+currentLayer];
newLayer.load(url, 500);
oldLayer.visibility = 'hide';
oldLayer.zIndex = 1;
newLayer.zIndex = 2;
newLayer.visibility = 'show';
}
</script>
</head>
<body>
<a href="test.html"
onclick="changeLayer(this.href); return false;">TEST</a><br>
<a href="home.html"
onclick="changeLayer(this.href); return false;">HOME</a><br>
<hr>
<ilayer name="ilayerName" id="ilayerName" width=500 height=500>
<layer name="lName0" id="lName0" src="home_load.html"
width=500 height=500 z-index="2"></layer>
<layer name="lName1" id="lName1" src="home_load.html"
width=500 height=500 z-index="1" visibility="hide"></layer>
</ilayer>
<hr>
</body>
</html>
You will have to try it out and see what you think.
Richard.