Entry
How do I capture the back button of the browser and disable it?
How can I use eventhandler with a parameter?
May 24th, 2001 04:54
Colin Fraser, Nivedhitha Raman, meng xianhui,
There is no way to do this, but what you may be able to do is to open a
new window with the back button inactive or perhaps without a toolbar
at all.
There is another possibility, use the replace function :
<SCRIPT LANGUAGE="JavaScript"><!--
if (document.images)
location.replace("http://www.faqts.com");
else
location.href = "differentpage.htm";
//--></SCRIPT>
The followup question from Meng Xianhui reads :
"How can I use eventhandler with a parameter?"
I am not sure why you would want to do that here. The orginal question
was about disbling the back button which is not possible, so all you can
do is to replace the last history item with a new one. In the code
above this happens automatically when the page is laoded. However, this
code below may be handy for another purpose, but I am not sure what.
<SCRIPT LANGUAGE="JavaScript"><!--
var dest = new
Array('http://www.faqts.com','http://www.microsoft.com',''http://www.cis
co.com');
function newBack(i) {
if (document.images)
location.replace(dest[i]);
else
location.href = "differentpage.htm";
}
//--></SCRIPT>
And in the body :
<form>
<input type="button" value="FAQTS" onClick="newBack(0)">
<p>
<input type="button" value="The Dark Side" onClick="newBack(1)">
<p>
<input type="button" value="The Borg" onClick="newBack(2)">
</form>
This is untested but it should work in both IE and NN. No garantees.