Scrollbar help?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2006
Posts: 3
Reputation: Nouvelle is an unknown quantity at this point 
Solved Threads: 0
Nouvelle Nouvelle is offline Offline
Newbie Poster

Scrollbar help?

 
0
  #1
Nov 12th, 2006
I need serious help with Scrollbars. how can i position them so they go exactly where i need them. say on a picture i need it in the circle area how can i get it there and what do i need to do? Could somebody point me in the right direction or towards a tutorial?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,082
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Scrollbar help?

 
0
  #2
Nov 13th, 2006
Originally Posted by Nouvelle View Post
I need serious help with Scrollbars. how can i position them so they go exactly where i need them. say on a picture i need it in the circle area how can i get it there and what do i need to do? Could somebody point me in the right direction or towards a tutorial?

Thanks
Its a bit hard to understand what you want to do exactly.

Do you want to move the scrollbar to a specific position?
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 154
Reputation: katarey is an unknown quantity at this point 
Solved Threads: 20
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Re: Scrollbar help?

 
0
  #3
Nov 13th, 2006
picture i need it in the circle area how can i get it there and what do i need to do?
Please clearify what is the quetion is
Last edited by katarey; Nov 13th, 2006 at 6:18 pm.
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 3
Reputation: Nouvelle is an unknown quantity at this point 
Solved Threads: 0
Nouvelle Nouvelle is offline Offline
Newbie Poster

Re: Scrollbar help?

 
0
  #4
Nov 13th, 2006
yeah i need to know how to move it to a certain area on the photo, sorry for the vague descrition.... woulda picture being posted help?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Scrollbar help?

 
0
  #5
Nov 13th, 2006
You cannot control the position of the scrollbars.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 3
Reputation: Nouvelle is an unknown quantity at this point 
Solved Threads: 0
Nouvelle Nouvelle is offline Offline
Newbie Poster

Re: Scrollbar help?

 
0
  #6
Nov 13th, 2006
so i cant move it anywhere? then howcome on some web pages they have it positioned to go along with the picture.

such as.. the picceh above
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,082
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Scrollbar help?

 
0
  #7
Nov 13th, 2006
Not sure what you mean by "positioned to go along with the picture. ". I might just be looking at it from the wrong angle..

As for moving the scrollbar, yes you can do it with JavaScript. Its a bit tricky, but not too complicated.

If you're working with a vertical scrollbar, heres the properties of the scrollbar.

Assume you have an element (el) of ID = mydiv.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var el = document.getElementById('mydiv'); // div element
  2.  
  3. var h = el.scrollHeight; // height of div scroll
  4. var y = el.scrollTop; // vertical scroll offset from top (of scrollHeight)
  5. var c = el.clientHeight; // scroll bar height

To change where the scrollbar is you'll just be modifying the scrollTop property of the element (that has the scrollbar you want to move).

Eg:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. el.scrollTop + 5; // move vertical scroll 5px down
  2. el.scrollTop - 5; // move vertical scroll 5px up

The scrollTop property shows how many pixels from the top the scrollbar is. So if you want to move it up right to the top, its just el.scrollTop = 0;

However, if you want to move it to the bottom, there is not scrollBottom property, you'll still have to use scrollTop. If you just need it right at the bottom, just make scrollTop an extremely large number like: el.scrollTop = 5000; . That will move it down 5000 px, which is more than any normal screen resolution (I think).

If you want to know specifically how many pixels you are from the bottom, you'll have to use something like:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var el = document.getElementById('mydiv'); // div element
  2.  
  3. var h = el.scrollHeight; // height of div scroll
  4. var y = el.scrollTop; // vertical scroll offset from top (of scrollHeight)
  5. var c = el.clientHeight; // scroll bar height
  6.  
  7. var scrollBottom = h - (y + c); // offset of scroll from bottom

or you could make it a property of all HTML elements.. so you can use it withought writing all that code over and over..

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1.  
  2. HTMLElement.prototype.scrollBottom = function() {
  3. var el = this; // element
  4.  
  5. var h = el.scrollHeight; // height of element scroll
  6. var y = el.scrollTop; // vertical scroll offset from top (of scrollHeight)
  7. var c = el.clientHeight; // scroll bar height
  8.  
  9. var scrollBottom = h - (y + c); // offset of scroll from bottom
  10.  
  11. return scrollBottom;
  12. }

You'd use it like el.scrollBottom();
(not sure how to set just a regular property).

ref:
http://www.quirksmode.org/js/doctypes.html
http://www.mozilla.org/docs/dom/mozilla/protodoc.html
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Scrollbar help?

 
0
  #8
Nov 13th, 2006
All of the above post is related to events generated by the scrollbar. They won't help you "position it".

In your example, the image is likely in an IFRAME. The scrollbar is attached to the frame, not the image.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,082
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Scrollbar help?

 
0
  #9
Nov 13th, 2006
Originally Posted by tgreer View Post
All of the above post is related to events generated by the scrollbar. They won't help you "position it".

In your example, the image is likely in an IFRAME. The scrollbar is attached to the frame, not the image.
oh duh.. you wanna move the scroll bar itself.. lol.. unfortuantely, not possible.

You can create a custom HTML element that looks like and functions like a scrollbar, and place it where ever you want, but it would be a ton of code, if possible...
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: Scrollbar help?

 
0
  #10
Nov 14th, 2006
you can use bookmarked anchor tags to position the user's view somewhere. combined with some absolute positioning over the part of your image you want in focus, and a bit of offset calculation (you'll see what I mean if you take the <br/> parts out of the <a> tags), you'll get something like the effect you described...

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a rel="nofollow" class="t" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" target="_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>">
  2. <html>
  3. <head>
  4. <title>Anchor Bouncing</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6. </head>
  7. <body>
  8. <img src="big_picture.gif" width="100%" height="1000px"/>
  9. <a name="place1" style="position:absolute;left:100px;top:50px;" href="#place2"><br/><br/><br/><br/><br/>Place 1 is here</a>
  10. <a name="place2" style="position:absolute;top:400px;left:50%;" href="#place3"><br/><br/><br/><br/><br/>Place 2 is here</a>
  11. <a name="place3" style="position:absolute;left:50px;top:700px;" href="#place1"><br/><br/><br/><br/><br/>Place 3 is here</a>
  12. </body>
  13. </html>

i've uploaded it so you can see it working:

http://www.fusiongroupuk.com/anchorbouncing/index.html

try:

http://www.fusiongroupuk.com/anchorbouncing/index.html#place1
http://www.fusiongroupuk.com/anchorbouncing/index.html#place2
http://www.fusiongroupuk.com/anchorbouncing/index.html#place3

or click the anchors to bounce about =P
Last edited by MattEvans; Nov 14th, 2006 at 2:09 am. Reason: , != .
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC