Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1254 What are the different ways of accessing an anchor

You are here: irt.org | FAQ | JavaScript | Link | Q1254 [ previous next ]

The following code will all move the browser to the 5th anchor on the page in a frame named main. Please note that Internet Explorer 4 does not like to go to a named anchor using the anchors array so either use document.all.anchor5 or document.anchors[4]

Remove parent.main. and TARGET="main" if the anchor is on the same page as the link to it.

<a href="anchors.htm" target="main"> href=anchors.htm</a>

<br>

<a href="anchors.htm#anchor5" target="main">anchors.htm#anchor5</a>

<br>

<a href="javascript:;" onClick="
    parent.main.location.hash='anchor5';
    return false;
">location.hash='anchor5'</a>

<br>

<a href="javascript:;" onClick="
    if (document.layers)
        parent.main.scrollTo(0,parent.main.document.anchors['anchor5'].y);
    else
        if (document.all)
            parent.main.document.all.anchor5.scrollIntoView();
    return false
">scrollintoView/scrollTo</a>

©2018 Martin Webb