gpt4 book ai didi

javascript - Event.ClientX 在 firefox 和 chrome 中不工作

转载 作者:行者123 更新时间:2023-11-30 07:17:21 26 4
gpt4 key购买 nike

我的编码在 IE 中有效,但在 Firefox 和 Chrome 中无效...

 function handleWindowClose() {
if ((window.event.clientX < 0) || (window.event.clientY < 0))
{
event.returnValue = "Are You sure to leave this page";
}
}
window.onbeforeunload = handleWindowClose;

谁能帮帮我...

最佳答案

window.event 是 IE 独有的东西。要让它在其他浏览器中工作,您必须将事件作为处理函数的参数获取:

function handleWindowClose(e) {
e = window.event || e;
if ((e.clientX < 0) || (e.clientY < 0))
{
e.returnValue = "Are You sure to leave this page";
}
}
window.onbeforeunload = handleWindowClose;

关于javascript - Event.ClientX 在 firefox 和 chrome 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10045351/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com