Jumping to name anchors in HTML pages from a POST operation


I need to jump to a named anchor (<A HREF='name'>) section in the document after a FORM POST operation. Using #name on the URL does not seem to work consistently.

Named anchors are handy for jumping into a page and displaying a specific section of that page. You can do this by loading the page and having the browser jump to the page with:

<a href='SomePage.htm#NamedAnchor'>

This works well for static requests, but gets tricky when the request is dynamic. The HTML spec doesn't clearly define where the anchor reference should go, before the QueryString question mark or after. In any case, it doesn't work well for either IE or Netscape.

Another solution is to add a small bit of JavaScript to the bottom of the HTML page:

<script language='JavaScript'><!--
window.location.href='#gohere';
//--></script>

It needs to be on the bottom so this code doesn't fire until the page anchor is already loaded or else this code will fail.


Last Updated: 03/26/99