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

Disabling BACK button in IE4

Status
Not open for further replies.

stu

Programmer
Jan 22, 1999
1
US
Hello, I am trying to find or write some VBScript or Javascript that will disable the browser's BACK button when a user hits my ASP. Any help would be appreciated. Stu
 
The only way I can see to do this is to disable the menubar using the window object or flushing the contents of the history object. So that it is empty. But then who am I to say...
 
I used inverse logic. Basically I coded an event handler<br>
in the on unload event. I also coded an onclick event.<br>
If the user clicked on a hyperlink or button on my page<br>
I set a variable to true. When the unload event is fired<br>
the code examines the variable to see if the user clicked<br>
a control on the page. If he hit the back button this variable is false and I use client side redriecttion.<br>
top.window.location.href = "URL" to redirect the client<br>
to any page on my site. This in effect breaks the back button. An unfortunate side effect is that it also breaks<br>
the favorites/bookmark control also preventing the user from<br>
leaving my site. I am still working on that one.<br>
<br>
this is my script.<br>
<br>
&lt;Script&gt;<br>
SUB Link_Onclick()<br>
ClickedOnLInk = True<br>
End Sub<br>
<br>
<br>
Sub t_unload()<br>
If ClickedONlink = False then<br>
top.window.location.href = "myurl"<br>
<br>
End if<br>
<br>
End SUB<br>
<br>
&lt;/SCRIPT&gt;<br>
<br>
<br>
On the PAGE<br>
&lt;body OnUnload = "t_unload()"&gt;<br>
<br>
&lt;a href= "URL" Onlclick = "Link_OnClick"&gt;Click Here &lt;/a&gt;<br>
blah<br>
blah<br>
blah<br>
<br>
&lt;/body&gt; <br>
<br>
<br>
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top