It can be done in 4+ browsers but it doesn’t really disable the back button, just erases the data behind it to an extant.
replace Method
The replace method replaces the current History entry with the specified URL. After calling the replace method, you cannot navigate back to the previous URL using the browser’s Back button.
Syntax: location.replace(URL)
This will replace the history with the current link every time a link is clicked
<BLOCKQUOTE><font size=“1” face=“Verdana, Arial”>code:</font><HR><pre>
<SCRIPT>
function getTag(el,str) {
while ((el!=null) && (str.indexOf(el.tagName + “:”)<0))
el = el.parentElement
return el
}
function navigateTo(sURL,target) {
if ((target == ‘_self’) | | (target==“”)) {
window.location.replace(sURL);
return false;
}
if (target == ‘_top’) {
top.window.location.replace(sURL);
return false
}
if (target ==‘_parent’) {
parent.window.location.replace(sURL);
return false;
}
if (target == ‘_blank’ | | parent.frames.length < 1) {
window.open(sURL, target);
return false;
}
else {
if (parent.frames[target])
parent.frames[target].location.replace(sURL);
else
window.open(sURL, target);
return false;
}
}
function checkIEClick() {
var el = getTag(event.srcElement,“A:AREA:”)
if ((el!=null) && ((el.tagName==“A”) | | (el.tagName==“AREA”))) {
event.returnValue = false
navigateTo(el.href,String(el.target).toLowerCase())
}
}
function checkNSClick(ev) {
if (ev.target.href) {
navigateTo(ev.target.href,String(ev.target).toLowerCase())
return false
}
}
if ((document.all) | | (document.layers))
if (document.layers) {
document.captureEvents(Event.CLICK)
document.onclick = checkNSClick
}
else
document.onclick = checkIEClick
</SCRIPT>
A little slick redirection:
<BLOCKQUOTE><font size="1" face="Verdana, Arial">code:</font><HR><pre>
<META HTTP-EQUIV="Refresh" CONTENT="1; <A HREF="http://www.insideDHTML.com/home.asp">" TARGET=_blank>http://www.insideDHTML.com/home.asp"></A>
<SCRIPT>
<!--
var version = parseInt(navigator.appVersion)
// replace is supported
if (version>=4 | | window.location.replace)
window.location.replace("newPage.htm")
else
window.location.href = "newPage.htm"
// -->
</SCRIPT>
The document, <A HREF="newPage.htm">Scott's Home</A> has moved.
The above code was found at Site Experts. I hope it is useful.
Wayne Luke - Sitepoint Forums Administrator
Digital Magician Magazine - MetaQuark Creations (Coming Soon)
sitepoint@digitalmagician.com
[This message has been edited by wluke (edited August 03, 2000).]