gpt4 book ai didi

javascript:窗口外的事件

转载 作者:行者123 更新时间:2023-11-28 08:59:46 25 4
gpt4 key购买 nike

是否可以获取在浏览器窗口之外触发的鼠标事件?或者当鼠标移动到窗口上时是否可以检查鼠标是否被按下?

最佳答案

这是不可能的,但是从这句话来看 -

Or is it possible to check if the mouse is pressed when the mouse is moved over a window

您可以检查页面何时获得焦点,以及何时有人切换回您的页面选项卡。

window.onfocus = function() {
console.log('focus');
alert('focus'); // See note
};

Note - If you use alert in the onfocus event the alert will popup multiple times. This only happens with alert and must be a bug somewhere, maybe someone can shed some light on it.

Demo

关于javascript:窗口外的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17902839/

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