Javascript 如何限制鼠标侧键导致的浏览器后退功能?
我有一个应用程序,它向用户展示了一组问卷,使用框架显示。我想限制用户使用鼠标侧按钮前后导航,每个框架上都有导航按钮,我不想在限制鼠标侧按钮时损害按钮的功能 我已经使用javascript限制了键盘上的浏览器返回功能,但无法限制鼠标侧按钮。看来是这样,下面是向他介绍的解决方案>Javascript 如何限制鼠标侧键导致的浏览器后退功能?,javascript,jquery,Javascript,Jquery,我有一个应用程序,它向用户展示了一组问卷,使用框架显示。我想限制用户使用鼠标侧按钮前后导航,每个框架上都有导航按钮,我不想在限制鼠标侧按钮时损害按钮的功能 我已经使用javascript限制了键盘上的浏览器返回功能,但无法限制鼠标侧按钮。看来是这样,下面是向他介绍的解决方案> window.onload = function () { if (typeof history.pushState === "function") { history.pushState("jib
window.onload = function () {
if (typeof history.pushState === "function") {
history.pushState("jibberish", null, null);
window.onpopstate = function () {
history.pushState('newjibberish', null, null);
// Handle the back (or forward) buttons here
// Will NOT handle refresh, use onbeforeunload for this.
};
}
else {
var ignoreHashChange = true;
window.onhashchange = function () {
if (!ignoreHashChange) {
ignoreHashChange = true;
window.location.hash = Math.random();
// Detect and redirect change here
// Works in older FF and IE9
// * it does mess with your hash symbol (anchor?) pound sign
// delimiter on the end of the URL
}
else {
ignoreHashChange = false;
}
};
}
}
您可能可以使用一些javascript onclick方法捕获事件,但我不明白您为什么需要它。你无法阻止某人回头,为什么要用相框?这是21世纪的“如何限制浏览器返回功能…”为什么不创建一个web应用程序。没有用户诅咒你、你的孩子和你孩子的孩子?或者换句话说,设计你的网络应用程序。这样,当用户点击后退按钮时,它不会中断。