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

Q594 Is there a way to unconditionally direct the browser to an anchor tag?

irt.org | Knowledge Base | JavaScript | Link | Q594 [ previous next ]

Q594 Is there a way to unconditionally direct the browser to an anchor tag?

Try:

<html>

<head>
<script language="JavaScript"><!--
function relocate(hash) {
    if (location.hash != hash) {
        if (document.images)
            location.replace('http://www.somewhere.com/page.htm#' + hash);
        else
            location.href = 'http://www.somewhere.com/page.htm#' + hash;
    }
}
//--></script>

</head>

<body onLoad="relocate('myAnchor')">

....

<a name="myAnchor"></a>

</body>
</html>

Feedback on 'Q594 Is there a way to unconditionally direct the browser to an anchor tag?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


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