Javascript Help!!
- Started
- Last post
- 11 Responses
- defunktion
I created a page thaat uses anchor points horizontally, only to find out that it doesn't work so well on Mac.
I've realised I'm going to have to find a Javascript horizontal anchor point scroller.
I've searched via Google and cannot find anything, please, please can somebody point me to the right code/website!
For an example of what I'm looking for goto
http://www.warprecords.com/ograp…
And click "Questions"
- ilmarine0
the example you provided only works when you have the stuff you want to scroll in predefined box (eg. in an iframe, like that site.) basically it takes the width of the iframe and multiplies it by something. the mupltiplier (eg. 2 or 3 - denoting the page) is past alog in the link.
var mult = 480;
var pos = 0;
var speed = 40;function scr(targ)
{
xtarg = (targ*mult);
while (pos!=xtarg){
pos = pos + speed;
scrollTo(pos,0);
}
}var mult is the width of the iframe.
var pos is the current position (leave it 0)
var speed is the number of pixels, by which it scrolls.then every link (the arrow to another page) has a href like this >> Javascript:scr(1)
where the number denotes the page.hope this explains.
p.s. however, the script is faulty, because when you scroll it horsiontally to a point with you mouse and then press some arrow it scrolls itself til the end.
- defunktion0
There will only be a start point and an end point on mine (two 'pages'). Also, it is in an iFrame. So I guess this code from Warp might actually work!
Do you know of any other Java anchor scripts?
- ilmarine0
i have never searched fo one. so nope.
it is possible to make this code work for any number of pages, but unfortunately i don't have the time.
- defunktion0
Thanks for your help so far.
I have got the script working to scroll to the right hand page, but I can't work out how to get it to scroll back to the left hand page.
Any ideas?
- defunktion0
I just found that Varspeed is the speed at which it scrolls. Handy!
- unknown0
javascript sucks!
But for some things it's pretty neat, but for almost everything else it sucks!
- ilmarine0
i guess the easiest way (for me not to start rewriting the code ;) would be if you just made another function with another name, changed the plus sign in there to minus and made a link that point to this new function and uses the previous page number. this should work.
- defunktion0
Hey,
function scr(targ)
{
xtarg = (targ*mult);
while (pos!=xtarg){
pos = pos + speed;
scrollTo(pos,0);
}
}Are you referring to a modified version of this piece of code? Where would I put the minus?
- ilmarine0
pos = pos - speed
- defunktion0
That half worked. It moves left now, but, it locks the browser after mving the frame left.
Something needs changing.
- defunktion0
*BUMP*
(I still need some help moving the browser right)