Link to home
Start Free TrialLog in
Avatar of sp400
sp400Flag for Spain

asked on

history.clear or avoid BACK

I need a function for avoid the user going back in the history.
The ideal can be an equivalent to history.clear, this way the visible page would be the only and the back doesn't work.

I can open a window without toolbar, but the user can use the keyboard or the mouse+right menu.

Of course I'm looking for the most compatibility in several browsers (IE, NetScape, FireFox...)

I've code for the back event and can delete, but works only in IE and doesn't avoid the right-menu-back.

I hope this question has been made previously but i can't found.
Thanks in advance.



Avatar of Batalf
Batalf
Flag of United States of America image

Maybe

<body onload="history.forward()">

on your pages.
Due to security issues, you have no access to manipulate the users history.
Avatar of ljo8877
ljo8877

I suspect you only want to keep the user from going back to one of your sites pages; one that calls a second page.

Let's say page1.html has a link (form action, etc) to page2.html

<a href="location.replace('page2.html');">Page 2</a>
Avatar of sp400

ASKER

Let's me clarify:

I've several pages that the end-user needs to be completed in order, and navigate only using objects in the pages.

I need be sure that the end-user can't goin' Back and resend.
If the end-user needs to visit a moment other page, simply he can open other browser window.

my application is intend to be used for a few and controlled users.
this application is a replacement of an old application, and need this behavior.
You cannot remove previous history entries. However, location.replace(url) overwrites the current history entry. So once the user moves to the next page they cannot go back to the previous page by clicking the back button. If they click the back button, they will go back to before your first page (assuming you use the replace method on each page). If they click back and then forward, they will skip directly to the last page they were working on.
You can start your process by open a window without the toolbar or a new browser with tool bars it will have the same results. Even without a tools bar a user can right click and select back. In either case, a new window with or without a toolbar has an history with only the current page. Your task is to keep it that way, by replacing the page each time the user moves forward.

window.open("url", "name", "toolbar=no"); will give a window without a toolbar, and it has no old history

but <a href="url" target="_blank">click</a> will give a browser with all the chrome, but without old history.

location.replace("url") will keep the history to the current page.
 
Avatar of sp400

ASKER

open a new window for each submit page is not acceptable.

I can start the transaction (i.e. the first page) with an window.open with empty history, but when the end-user press back in the page 4 (any > 1) i need control about it.

this behavior is repeted in some transactions, please don't suggest any about programming in the server side, i need do it in client side.
No, you misunderstood me. Open a new window for your whole process with the first page and use that window for every page thereafter using the replace method in that window. Doing that, the window's history will always be the current page and no more. There will be no back to go back to even on page 4.
Avatar of sp400

ASKER

Thanks. I'll try tomorrow.
ASKER CERTIFIED SOLUTION
Avatar of ljo8877
ljo8877

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sp400

ASKER

Thanks for your ideas.
sorry the delay!