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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prohibit Navigational Freedoms

Status
Not open for further replies.

dakota81

Technical User
May 15, 2001
1,691
US
I'm building a custom app through the web for a select few people. I want to prohibit the use of the back button, mouse buttons set to navigation, the backspace key, menu navigation (view >> go to >> back), etc.

Basically speaking, I never want the users to be able to access any page in the browser history. Can I do it and how? I am building this app to work with IE exclusively.
 
Open your site in a new window and manipulate the history object using the replace() method for all of your links.

This won't 'prohibit' the use of any browser functionality, but it will render the back button, right-click -> back and view -> go -> back and backspace keys quite useless.
 
Could you please elaborate on how I would manipulate the history object?
 
Just curious of the reason. Never seen a site where Im not suppose to go back.
 
To answer Kjonnnn; I'm building a custom app for where I work to handle order entry, invoicing, call management, etc.

Thanks for the help on the links, though for the application I'm putting together, almost all navigation is done through form submition... Can something be rigged up for this situation?

I should be able to have the first page open in a new window and I'd leave out all the toolbars and menus, and stop any right-clicking, but the backspace key will still be there.

This just seems like such a simple concept...
 
Or maybe from a different approach, is there an event that is triggered when accessing the history where I can stop any attempts? Again, I'm building this app for IE only.
 
You could build a function which looks at the length of the history object - location.replace() nulls out the history - and if there is a history there (ie history.length > 0) use location.replace(location.href) to replace the current page with itself, nulling out the history (no going back)
Code:
function checkHistory(){
 if(history.length > 0){
  location.replace(location.href);
 }
}

<body onload=&quot;checkHistory()&quot;>
 
Appreciate all the effort; the last suggestion is just putting the pages into a constant state of refreshing themselves... I'll definately search around google and see if I can expand on that idea.
 
I think I've got the solution I need by placing this at the beginning of all the pages (or with ColdFusion in the Application.cfm file):

<script language=&quot;JavaScript&quot;><!--
javascript:window.history.forward(1);
//--></script>

With my ColdFusion app, all the form processing is done within the ColdFusion server, and I believe IE just brings up the local cached version of the page.
 
<script language=&quot;JavaScript&quot;>
<!--
javascript:window.history.forward(1);
//-->
</script>


That wil only prevent them going back if they have js enabled.

almost all navigation is done through form submition... Can something be rigged up for this situation?

If your page is populated by data from a form, the previous page should expire when you submit the data so the back button is useless anyway.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
The app I'm writing, all form data is dealt with by the coldfusion server and never becomes processed by the web browser, so the back button is an issue, even with some instances there are regular links, or I change the url of a frame.

The javascript solution is perfect too because I'm not building an app to be cross-browser, multi-OS compatible; I just need it to be compatible with one specific browser, and it just happens that IE seems the easiest to write JavaScript for, and supports more css features that I need.

Thanks for everyone's help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top