Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Misc | Q1044 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.