TrainBeaser for iPhone
The moose likes HTML, CSS and JavaScript and the fly likes disabling back and forward button using included javascript file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "disabling back and forward button using included javascript file" Watch "disabling back and forward button using included javascript file" New topic
Author

disabling back and forward button using included javascript file

B Bhutta
Greenhorn

Joined: Jun 28, 2002
Posts: 14
Hi,
I want to disable my back and forward buttons and I want to use an included file to call that function.
If I simply add this line of code:
"history.forward();"
It will work and there is no problem. However, in this case I have to add this line of code on each hmtl page. However, since we have a common javascript file, common.js, I created a method in this file as:
"function clearHistory()
{ history.forward();}"
and I included this file using :
script src="common.js"
and I call clearHistory method in onLoad mehtod of an html page "(on_Load="javascript:clearHistory();" )" but it doesn't work.
Does javascript source file doesn't get included before onload!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
If you have control over the links, you can use
document.location.replace that will overwrite the history of the current page.
alos look at this
http://www10.brinkster.com/A1ien51/basics/backbutton.htm
The onload event occurs after the entire page is loaded!
Eric
 
 
subject: disabling back and forward button using included javascript file
 
Threads others viewed
which method will be called first
clearing history and disabling back and forward buttons
How do you check if a user is going back to the previous page (history.back)?
body tag onload event does not fire
body onload() alternative
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture