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

Q1044 How do I direct the browser to an anchor on a dynamically generated page from within that dynamically generated page?

You are here: irt.org | FAQ | JavaScript | Misc | Q1044 [ previous next ]

Try:

<frameset cols="25%,*">
    <frame src="links.htm">
    <frame src="about:blank" name="main">
</frameset>

and then in links.htm:

<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.anchors[4].scrollIntoView();
  return false"
>scrollintoView/scrollTo</a>


<script language="JavaScript"><!--
function loadDynamic() {
    parent.frames['main'].document.open();

    var output = '\
    <a name="anchor1">anchor1<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre> \
    <a name="anchor2">anchor2<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre><a name="anchor3">anchor3<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre><a name="anchor4">anchor4<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre><a name="anchor5">anchor5<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre> \
    <a name="anchor6">anchor6<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre> \
    <a name="anchor7">anchor7<\/a> \
    <pre> \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
     \
    <\/pre>';

    parent.frames['main'].document.write(output);
    parent.frames['main'].document.close();
}
//--></script>

<form>
<input type="button" value="dynamic" onClick="loadDynamic()">
</form>

©2018 Martin Webb