faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

430 of 555 people (77%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

Can I clear the history list?
Can I disable the back button?

Jan 29th, 2003 10:55
Martin Hiestand, Martin Honnen,


You cannot clear the existing history but you can make sure a newly 
selected page replaces the previous one preventing building up a 
history. You do so by calling
  location.replace('newPage.htm');
instead of assigning 
  location.href = 'newPage.htm';
The location.replace('url') call will replace the current page in the 
history list with the new page thus preventing backing to the current 
page.
You might also use that in a link with
  <A HREF="newPage.html"
     ONCLICK="location.replace(this.href); return false;"
  >new page</A>

The back button cannot be disabled besides using the above technique 
for preventing backing or besides opening a new window without 
toolbar/menubar.

Remark:
The back button will be disabled if you first open a new window and 
then proceed with location.replace as shown above.