Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete history ?

Status
Not open for further replies.

paragvshah

Programmer
Jan 11, 2001
109
0
0
IN
Hi friends,

I want a logic that will delete my history when user saves his profile. So that he wont be able to visit previous pages that he has come thru. Please tell me how this can be done thru javascript.


Parag
 
You can't delete the entire history on the users computer. Would you want someone doing that to you!

You can use location.replace() within your site so that no history is maintained of the users navigation through your own site.

Greg.
 
I have used location.replace() but facing a problem here. I am sending code for 3 sample files. I am calling test.htm which has a link. This link calls test1.htm which has location.replace() function which calls test2.htm. So on clicking this link, it opens test2.htm but when I click on back button it takes me back to test.htm. I don't want the user to go back to test.htm but he should remain in test2.htm.

The code is given below:

test.htm
--------
<A href=&quot;test1.htm&quot;>Test</a>


test1.htm
----------
<script language=&quot;Javascript&quot;>
window.location.replace('test2.htm?test=1');
//--></script>


test2.htm
---------
Test2


I want this utility in a registration form. Once a user has saved his info I am showing a confirmation message. Though the user can click Back button and again access the registration form page which I would like to avoid.

Parag
 
Parag,

You need to use the location.replace() method on page 1.
Code:
test.htm
--------
<A href=&quot;javascript:location.replace('test1.htm');&quot;>Test</a>

My browser starts up in Google. I just ran that same test using the location.replace() method in the first page. Ran through the pages, and all the back buttons took me back to Google.

Remember what Greg said is true. You can't erase Google or any other item from a visitor's history so the only way you can truly be successful in disabling the back button is to open test.htm in a new window, then navigate with location.replace(). The back button will never be an option for that visitor in that new window.

ToddWW
 
Can you apply this method to a form?

Something like ...

<cfform name=&quot;cart&quot; method=&quot;POST&quot; action=&quot;javascript:location.replace('index.cfm')&quot;>
 
That's a very good question and definitely worth trying. Let me know how it works out.

I have heard of people posting forms to a new window which essentially leaves it out of the main window's history, but I've never tried or tested either.

ToddWW
 
Here's an example of posting a form to a new window. Was given to me by another member, so don't give me the credit for it and I haven't tested it.

Code:
function submitForm() {
  window.open('blank.html','sendpost');
}



<form name=&quot;calform2&quot; action=&quot;/tms/sendUpdate.jsp&quot; method=&quot;POST&quot; target=&quot;sendpost&quot; onSubmit=&quot;submitForm();&quot;>

Notice the window name and the form target are the same. Supposedly this works !!

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top