...

View Full Version : Can I scrollBy(100,0) to a target?



Steven_Smith
01-15-2003, 05:51 PM
Hi everybody.

I was wondering if it is possible to use the scrollby(xx,xx); to scroll to a #target rather then a pre-set distance. Below is a scroll script I wrote. (its not the best, if the speed doesn't devide into the distance evenly it doesn't scroll to the right position)

Hmmm. any ideas?

thanks
steven



function scroller(distance,direction){
var i=0
var speed=10
var pixels=speed
if (direction=="back"){ pixels=pixels-(pixels*2) }
while(i < (distance/speed)){
scrollBy(pixels,0)
i++
}
}

<a href="javascript:scroller(800,'back')" >back</a>

beetle
01-15-2003, 06:25 PM
What about scrollTo() ?

scrollTo( parseInt( document.links['yourLink'].offsetLeft ), 0 );

Mr J
01-15-2003, 06:58 PM
See if this helps you out


I created a script whereby you can allocate keywords to run a function that will scroll down or up the page to information relating to that keyword.

To see the script see

www.huntingground.freeserve.co.uk/scripts/scrl_hlite.htm

The main factor is how the target positions are located.

No fixed positions have been used as the locations are found by using

document.all[targetID].offsetTop



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum