Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving a layer for NS6+

Status
Not open for further replies.

TechnicalAnalysis

Programmer
Jul 2, 2001
169
US
Can someone tell me the JavaScript syntax to move a layer for Netscape 6+?

I know that it's something like this for Netscape4.x
document.layers.whichone.top=something;

And it's this for IE.
document.all.whichone.style.top=something;

What's it for Netscape 6?

Thanks
 
document.getElementById("layerID").offsetTop=number;
(for ie5+ - the same :) Victor
 
Thanks for the info. However, I've got the error of 'Setting a property that has only a getter'
Does that mean I fail to refer to the right layer?

On the .css file. I have, say,
#whichone {position: absolute; left: 0px; top: 0px; visibility: visible; z-index: 1}

<script language=JavaScript>
var pos=0;
function movethis() {
pos++;
document.getElementById(&quot;whichone&quot;).offsetTop=pos;
if (pos<=30) {
setTimeout(&quot;movethis()&quot;, 20);
}
}
</script>

<body onLoad=movethis();>
<div id='whichone'>
Blah,blah,.blah,.....
</div>
</body>


Regards
 
woops, sorry, my fault: offsetTop is only to get division's top value :)

try to use document.getElementById(&quot;whichone&quot;).style.top

i tryed it now, looks like it works :)
noone's perfect :)


~~~~~~~~~
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html>
<head>
<title>MOVE! MOVE! MOVE!</title>
<style>
#whichone {position: absolute; left: 0px; top: 0px; visibility: visible; z-index: 1}
</style>
<script language=JavaScript>
var pos=0;
function movethis() {
pos++;
//the following doesn't work
//document.getElementById(&quot;whichone&quot;).offsetTop=pos;
document.getElementById(&quot;whichone&quot;).style.top=pos;
if (pos<=30) {
setTimeout(&quot;movethis()&quot;, 20);
}
}
</script>
</head>
<body onLoad=movethis();>
<div id='whichone'>
Blah,blah,.blah,.....
</div>

</body>
</html>

~~~~~~~~~ Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top