如何在 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();">
但在 Firefox 中event.clientX和event.clientY 始终为 0。有没有其他方法可以找到它?