PDA

View Full Version : Way to scroll down a page?


me'
11-05-2003, 06:25 PM
Is there a function to scroll down the page? I'm sure this would be an easy question normally, but what about scrolling down a div with a fixed height?? I could use an iframe, but I'd much prefer it if I didn't.

This is what I'm doing: | |
| |
-------------------
| | ||
| | ||
| | ||
-------------------
| |
| |
| |
| |
| |
| |
| |
| |
----------------[/code]Basically, a div with oversized content and at the end of each section a 'more >>>' link to scroll down to the next screen of information. Because I'll have overflow: hidden;, this process will be invisible to the user.

COBOLdinosaur
11-05-2003, 11:29 PM
IE ONLY!!

Even thought the overflow is hidden an no scroll bars are rendered, the scroll properties still exist.

<html>
<head>
<title> scroll div</title>
</head>
<body>
<br />
<br />
<br />
<br />
<div id= "thediv" style="width:150px;height:150px;overflow:hidden">
1 <br />
2 <br />
3 <br />
4 <br />
5 <br />
6 <br />
7 <br />
8 <br />
9 <br />
10 <br />
11 <br />
12 <br />
13 <br />
14 <br />
15 <br />
16 <br />
17 <br />
18 <br />
19 <br />
20 <br />
21 <br />
22 <br />
23 <br />
24 <br />
25 <br />
26 <br />
27 <br />
28 <br />
29 <br />
30 <br />
</div>
<input type="button" value="Next"
onClick="document.getElementById('thediv').scrollTop+=100">
</body>
</html>

liorean
11-05-2003, 11:37 PM
Hmm, doesn't the scrollBy and scrollTo methods exist on each element aswell?

One way that I'v seen used for this, is to use clipping. As it's a feature I've never used myself, however, I can't tell you how it's done.

me'
11-06-2003, 04:56 PM
Any idea how to use the scroll* functions?

Had a dig around and I couldn't find any info.

COBOLdinosaur
11-06-2003, 10:39 PM
I tried:

onClick="document.getElementById('thediv').scrollTo(0,100)"

IE 6 returns the error "oject does not support this property or method, and Mozilla ignores it. So I would say the scroll methods do not work at the element level for a div. They work for page, frame, iframe, and textarea and perhaps tbody, but not for a div.