如何知道在firefox中是单击刷新按钮还是单击浏览器后退按钮...对于这两个事件onbeforeunload()方法都是回调.对于IE我正在这样处理:
function CallbackFunction(event) {
if (window.event) {
if (window.event.clientX < 40 && window.event.clientY < 0) {
alert("back button is clicked");
}else{
alert("refresh button is clicked");
}
}else{
// want some condition here so that I can differentiate between
// whether refresh button is clicked or back button is clicked.
}
}
<body onbeforeunload="CallbackFunction();">
Run Code Online (Sandbox Code Playgroud)
但在Firefox中,event.clientX和event.clientY 始终为0.还有其他方法可以找到它吗?