Scrolling down a HTML Layer
The following code is working well to scroll down the complete page. But I need only the DIV Layer to be scrolled down on HTML page load. Can anyb开发者_运维问答ody edit this code to scroll down DIV tag alone.
<html>
<head>
<script type="text/javascript">
function myScroll()
{
x = document.getElementById("myDiv");
h= x.clientHeight;
self.scrollTo(0,h);
}
</script>
</head>
<body onload="myScroll();">
<div id="myDiv">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Donec tristique lectus sit amet est. Vivamus sit amet lacus. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Morbi convallis sem nec lectus. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Nullam in odio ac augue porttitor semper. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Nam leo. Morbi varius molestie felis. Etiam egestas. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Donec vitae mauris vitae nisi gravida pharetra. In molestie eros eu tellus. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Suspendisse a mi vitae nulla vehicula lacinia. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Ut pellentesque lobortis ipsum. Quisque a leo. Curabitur tincidunt. </br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
Fusce est velit, condimentum sed, convallis in, blandit hendrerit, eros.</br></br></br></br></br></br></br></br></br></br></br></br></br></br></br></br>
</p>
</div>
</body>
have a look at: http://adp-gmbh.ch/web/js/scroll.html
you have to use ScrollTop = x.clientHeight
instead of ScrollTop = 0
精彩评论