Forum Moderators: open
[edited by: korkus2000 at 2:59 am (utc) on Nov. 1, 2003]
[edit reason] No sigs please [/edit]
<html>
<head>
<style type="text/css">
<!--
div{position:absolute;left:200px;top:800px;}
//-->
</style>
</head><body onload="scrollTo(200, 800)"><div>this div is 200px from the left and 800px from the top </div>
</body>
</html>
birdbrain
[edited by: korkus2000 at 6:15 pm (utc) on Nov. 1, 2003]
[edit reason] No sigs Please [/edit]
document.body.scrollTop = 250;
...but that only works in Mozilla and IE for the document.body object (Opera7 just sits ther for some reason?), and offsetTop is read-only so that won't work either. The window.scrollTo() method is the only way to go I guess. :)
--------
jamesa:
To get it to scroll all the way to the bottom you can do something like...
if (document.body.scrollHeight) {
window.scrollTo(0. document.body.scrollHeight);
}
else if (screen.height) { // IE5
window.scrollTo(0. screen.height);
} Jordan
You have made a slight error in your code...
using a
.instead of a
,in these lines
window.scrollTo(0. document.body.scrollHeight);and
// IE5 window.scrollTo(0. screen.height);
I presume that you require it scroll onload, so the script
would look something like this
<script type="text/javascript">
<!--
function doit()
{
if (document.body.scrollHeight)
{
window.scrollTo(0, document.body.scrollHeight);
}
else if (screen.height)
{
// IE5 window.scrollTo(0, screen.height);
}
}
//-->
</script>
with this in the body tag
onload="doit()"
birdbrain