Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language:
Expertise: Intermediate
Jun 22, 1999

"Disable" the Browser's Back Button

While there is no way to specifically disable the back button from within the browser, you can shortcut the navigation to another page. The trick is to catch the onbeforeunload event of the window:

 
<script language="VBScript">
dim curPage
dim canNavigate
canNavigate=false
curPage=document.location

function window_onbeforeunload()
	if not canNavigate then
		window.navigate curPage
	end if
	canNavigate=true
end function
</script>

Whenever anyone attempts to leave the page, the browser will nudge the user back. You can disable this functionality in code by setting the global variable canNavigate to true.

Kurt Cagle
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap