我正在做一个遗留项目,其中一个页面中有一些JS代码,即使我在IE11中运行,它也会强制将该页面的兼容模式更改为IE5。
我已经写了以下代码,它适用于除IE5以外的所有浏览器。
//Mouse Special back buttons trap code start
function PreventBrowserBack(){
window.location.hash="1";
window.location.hash="2";
}
PreventBrowserBack();
$(window).on('hashchange', function() {
window.location.hash="1";
});
function ApproveBrowserBack(){
window.location.hash="1";
window.location.hash="2";
}
//Mouse Special back buttons trap code End
document.onmousedown = function disableclick(event){
if(event.button==2)
{
alert("Right Click is not allowed");
return false;
}
};
由于当我们转到此页面时,某些JS代码强制将兼容模式设置为IE5,因此此代码无法工作。
请帮帮我。提前谢谢。
发布于 2017-02-21 15:43:06
使用navigator.userAgent
获取浏览器版本,例如if(navigator.userAgent== ...
document.getElementById("browserVer").innerHTML = navigator.userAgent;
<p id="browserVer"> </p>
https://stackoverflow.com/questions/42361095
复制相似问题