Forum Moderators: open

Message Too Old, No Replies

Scrolling a div using javascript

Need to add buttons to scroll a div 158px

         

eduardomaio

10:52 pm on May 29, 2005 (gmt 0)

10+ Year Member



Hi there,
I've seen this in a couple of websites, some of them picture gallerys but I can't find any of them. Can you help me?

I have a page at [xsi.eduardomaio.net...] with a div and overflow:auto. But, instead of having the scrollbar I would like to have 1 or 2 links to scroll the div to left or right, 158 pixels at a time.

I've Googled a lot and didn't find anything simple to make this, if you know any live example or any source code I would be truly apreciated.

eduardomaio

11:00 pm on May 29, 2005 (gmt 0)

10+ Year Member



Oh, also, a link to page.php#sumthin is out of question, as other galleries will have more pictures...

orion_rus

4:14 pm on May 31, 2005 (gmt 0)

10+ Year Member



scroll div is a very simple in javascript.
to understand how it do you need to put one div in another
like this:
<div>
<div>
text
</div>
</div>
first div should have overflow hidden and have fixed width and height. second should have a fixed height and not fixed width. Then you put a text to innerDIV you should detect new width with function clientWidth. and make changes with left style property.
Good luck to you