FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

how to page up with out using link anchor ?

 


phicha
is there a way to link to top or link to a part of page with out using link anchor ? i meant using javascript ?

regards,
Kaneda
phicha wrote:
is there a way to link to top or link to a part of page with out using link anchor ? i meant using javascript ?

regards,


You generally shouldn't, since that's what anchor tags are for, and you can style your way out of how they look anyway, so there's not that much point in using other elements.

That said, you can simply add this to any element's onclick (or onmouseup) handler(s):

Code:
window.location = 'http://www.google.com';


... or, for inpage links (name anchors):

Code:
window.location.hash = 'top';


... corresponds to <a href="#top">...</a>.

Doing such javascript linking with no actual <a> linking is discouraged, though, since search engine crawlers, screen readers etc. etc. will not be able to follow them - and since there's rarely any idea in using anything other than <a> for such links - when you can use stylesheets to make them look like you want.
phicha
i put a tag <a href="#top1"></a>
and in bottom of the page, i put

<a onclick="window.location.hash = 'top1'; >click here</a>

but when i test to click click here, the page don't go up ? why ?

thanks,
mathiaus
You need a named anchor. <a name="top1"></a>. What you had would link to the named top1 anchor.
phicha
eh sorry i wrote a wrong script already, thanks ^^"
it worked already. Very Happy
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.