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

Q244 How do I tell the browser not to save the current URL in the history folder?

irt.org | Knowledge Base | JavaScript | History | Q244 [ previous next ]

Q244 How do I tell the browser not to save the current URL in the history folder?

You cannot tell the browser to not store the URL in the history. What you can do though, for those browsers that support this, is to overwrite the current URL in the history when moving onto another page.

Normal links look like:

<A HREF="apage.html">Go to a page</A>

This can be done using JavaScript:

<SCRIPT LANGUAGE="JavaScript"><!--
function go(url) {
    location.href = url;
}
//--></SCRIPT>

<A HREF="javascript:go('apage.html')">Got to a page</A>

This can be enhanced to replace the current URL in the history:

<SCRIPT LANGUAGE="JavaScript"><!--
function go(url) {
    if (document.images)
        location.replace(url);
    else
        location.href = url;
}
//--></SCRIPT>

<A HREF="javascript:go('http://www.somewhere.com/apage.html')">Got to a page</A>

The check for the image object is the easiest way to detect if the browser supports the location objects replace()method.

Note: in Opera replace() will work, but only with absolute URL's.

Feedback on 'Q244 How do I tell the browser not to save the current URL in the history folder?'


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.