PDA

View Full Version : Looking for a script to make the page jump to a certain point when clicking a link


Dragonscales
09-11-2005, 06:13 PM
Hi all,
I am pretty new to javascripts and webpage building in general and would really appreciate any help you can give me with this problem. I want to incorporate links into the page that, once clicked, will jump further down the (same) page to the relevant information. Sort of like a "jump to top of the page" script but instead it jumps to a predetermined section of the same page.

I am unsure as to what this type of script would be called and every name I could think of brought back nil on google for the last few days, thus I am now asking for help lol

vwphillips
09-11-2005, 07:08 PM
see
http://www.vicsjavascripts.org.uk/PageNavigator/PageNavigator.htm


<A> anchors are positioned on the page

these must have a unique id

on linking find the top position of the anchor

and scroll to it using

window.scroll(0,(pnt));

where (pnt) is the top position of the anchor

find the top position of the anchor

by

document.getElementById('*AnchorID*').offsetTop

or better still

pnFTop(document.getElementById('*AnchorID*'));

using

function pnFTop(pn){
pnObjTop=pn.offsetTop;
while(pn.offsetParent!=null){
pnObjParent=pn.offsetParent;
pnObjTop+=pnObjParent.offsetTop;
pn=pnObjParent;
}
return pnObjTop;
}

Dragonscales
09-12-2005, 03:16 AM
Hi Vic,

Thanks for the suggestion, some nice work too!

I am after something like the layout on this page though http://www.vcps.au.com/contents/descriptions.htm

I'd really like the links to remain at the top of the page and be like html links. I want the page to sort of just jump downwards as well rather than scroll.

Thanks

*Edit - Oh, I probably should mention that I use Mozilla Firefox as a browser too, if that helps any or is relevant in any way.

_Aerospace_Eng_
09-12-2005, 03:46 AM
Is there a reason why you don't want to do this in regular html? http://www.w3.org/TR/REC-html40/struct/links.html

Dragonscales
09-13-2005, 05:56 AM
lmao no particular reason. I just thought I'd need to use javascript to do it. The joys of being a newbie I guess :/

Thanks for the link aerospace and all your help guys! :)