Forum Moderators: open

Message Too Old, No Replies

I wrote a quick script that works in IE but not in NS

I can't figure out why it doesnt work in NS

         

TheDave

6:47 am on Apr 14, 2003 (gmt 0)

10+ Year Member



Ok, basically what I'm trying to do is move something on the screen, here's the "supposed" netscape code, where "s" is a string with the name of the div I want to move, and "x" is where I want to move it to:

document.layers[s].style.left=x;

That doesnt work, so I tried:

document.layers[s].moveTo(x,y);

It's crazy, I wrote this script in about 5 minutes and it works perfectly in IE, but I have spent the last 2 hours trying to figure out why it won't work in netscape (I'm not so concerned with 4.x but the later netscapes). Grrr!

Thanks if you can point out any blatant errors (see my profile url +\test.asp for example)

RonPK

8:01 am on Apr 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello Dave,

document.layers[] is only supported by NN4. For the more recent Netscapes, which are based on Mozilla's Gecko engine and more or less comply with the Document Object Model, you should use document.getElementById():

document.getElementById('myLay').style.left = "100px";

This is also supported by IE 5 and up. For compatibility with IE 4 you need document.all[].

TheDave

11:19 pm on Apr 14, 2003 (gmt 0)

10+ Year Member



Thank you, I'll try that. :)