You are here: irt.org | FAQ | JavaScript | Bugs | Q1524 [ previous next ]
Affects: 4.x
If you put this in a layer <IMG name=img1 border=0 src="test.gif"> using the onLoad event handler, the image will disappear when the browser is resized.
Uncomment the commented line and comment the next to see that Netscape will look for a wysiwyg:// image
Solution is to give the image an absolute path either hardcoded or using the trick I have included
<html> <script> ie = (document.all); ns = (document.layers); h = location.href;(p=h.lastIndexOf("/")) > 0 ? homedir=h.substring(0,p+1) : homedir = ""; function load() { // html = '<a href="javascript:;)"><IMG name=img1 border=0 src="test.gif" onError="alert(\'error:\'+this.src)" onLoad="alert(\'loaded:\'+this.src)">Please resize window.</a>'; html = '<a href="javascript:;)"><IMG name=img1 border=0 src="'+homedir+'test.gif" onError="alert(\'error:\'+this.src)" onLoad="alert(\'loaded:\'+this.src)">Please resize window.</a>'; if (ie) document.all['lyrMain'].innerHTML = html; else if (ns) { document.layers.lyrMain.document.write( html ); document.layers.lyrMain.document.close(); } } </script> <body onload="load()"> <div id="lyrMain" style="position:absolute; top:100; left:100; width:400; height:400; background-color: #ddeeff; z-index:0; visibility:visible;"> Some text </div> </body> </html>