View Full Version : scroll to coords?
F.N.G.
01-22-2003, 07:42 AM
Just wondering if there is a script for scrolling to any verticle position onmousedown (without using links)...
In other words, if the mouse is depressed somewhere down a page, the scrollbar will move to become even with that position.
I did some searching, but found nothing remotely close, so I'm thinkin' not.
ez4me2c3d
01-22-2003, 01:23 PM
it's possible.
there's a JS method to get the cursor position
and there's a JS method to scroll the window
just put in your body tag the onMouseDown event handler then call your function that calculates the cursor position and then scrolls.
only probems i see for you are, scrolling if the page isn't at the dead top. because mouse postion is based on the viewable window not the page as a whole.
i may work on this just for kicks, let me know if you need more help.
anyone else?
Mhtml
01-22-2003, 02:07 PM
<script language="JavaScript" type="text/javascript">
function scrollIt(e) {
evnt = event;
y = window.evnt.y;
self.scrollTo(0,y*6.8)
}
</script>
ok you can call it any way that you want, just place the event in the body tag.
For example.
<body onMousemove="scrollIt()">
[edit:] To get around the viewable area problem I just multiplied by 6.8, I came to that number by simply trial and error.
I am using @ 1024x768 so possibly you should chuck in a res check which will multiply the y coord accordingly.
F.N.G.
01-23-2003, 02:21 AM
That's perfect; thank you both for the lesson.
I found it to work best using "onclick", by the way... as
with "onmousedown", the scrollbar was dysfunctional.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.