Does anyone know of a forward and back button script that will work well in IE and Netscape?
Hi Peter & Shin Ma,
history.go(-1) returns to the previous page
history.go(1) goes to the next page
history.go(0) refreshes/reloads the current page (I use it a lot when working with dynamic selection lists and netscape)
note for the first two to work there need be previous and next pages. you can insert any number within the parentheses. For example, history.go(-2) will go back 2 pages from the current one.
Placing the history.go(0) in an onLoad event handler will cause the page to fall into a loop. So, if you ever use it, do so only within a function that does not get called within the loading process.
Hope this clarifies some.
Continuing the theme of back and forward buttons:
Does someone know how to disable the back button so that user's cannot press it, please?
Strictly speaking, you can't. Browser's don't let you mess with the page history for security reasons.
Your only alternative would be to pop up a new browser window (using the window.open() property to prevent history from being copied to the new window).
Using the location.replace() method, you can create links that replace the current page in the browser history, rather than adding a new entry to the history. If you made all the links on your site with this technique, then you could prevent users from navigating backwards within your site.
You can also try putting a var in each page (eg, pageNum or DocName) and then in the body tag use the onload event handler to call a function that checks the value of the opener's variable. If it's higher than the one found in the current page, href the user to the appropriate page.