jwstairs
asked on
Disabling the Back and Forward Buttons in IE 5
Is it possible to disable to back and forward buttons in IE5 using javascript? If so how do you do it?
Cheers
Cheers
you cannot do it from the front end without using cookies..but you sure can do it using server side scripting...
using the location.replace() function you can make it so that no new history is being added to the history object. So, if you open a new window using javascript and use the locatiom.replace('newpage. htm') consistently, then you should have what you want.
regards.,
CJ
regards.,
CJ
Though this is not an elegant way of stopping the user from going back, if u think it is useful, u can try this. In the linked files, put this code in the script tag at the top of the page
window.history.forward(1)
Here are two files.
(1). "one.htm"
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
window.history.forward(1)
//-->
</SCRIPT>
</HEAD>
<BODY>
Here on Page one
<a href="two.htm">Go to Two</a>
</BODY>
</HTML>
(2). "two.htm"
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
window.history.forward(1)
//-->
</SCRIPT>
</HEAD>
<BODY>
Here on Page Two
<a href="one.htm">Go to One</a>
</BODY>
</HTML>
rgds
jcs
window.history.forward(1)
Here are two files.
(1). "one.htm"
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
window.history.forward(1)
//-->
</SCRIPT>
</HEAD>
<BODY>
Here on Page one
<a href="two.htm">Go to Two</a>
</BODY>
</HTML>
(2). "two.htm"
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
window.history.forward(1)
//-->
</SCRIPT>
</HEAD>
<BODY>
Here on Page Two
<a href="one.htm">Go to One</a>
</BODY>
</HTML>
rgds
jcs
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cookies can be used with client-side scripting, too, using document.cookies.
If you set a location cookie, then at the page start, you examine it, and if it's different than you existing location, then forward it to that location.
If the location cookie value is undefined, then set it to the actual location.
Maybe you should use another cookie value, a command, because if your user clicked a button, and go to a new page, then you shouldn't send her/him back to the previous page.
Stewe
document.cookie I mean. Sorry.
hongjun