<分区>
如何知道在 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。有没有其他方法可以找到它?