跳到主要内容

all

2023年06月08日
柏拉文
越努力,越幸运

afterscriptexecute


animationcancel


animationend


animationiteration


animationstart


auxclick


beforematch


beforescriptexecute


beforexrselect


blur


click


compositionend


compositionstart


compositionupdate


contentvisibilityautostatechange


contextmenu


copy


cut


dblclick


error


focus


focus 事件在元素获取焦点时触发。这个事件和 focusin (en-US) 最大的区别仅仅在于后者会事件冒泡。该事件不可取消,也不会冒泡。

语法

addEventListener('focus', (event) => { });

onfocus = (event) => { };

场景

  • 场景一、监听窗口焦点

    function screenCuttingMonitoring() {
    window.addEventListener("focus", function (event) {
    console.log(event);
    });
    }

    screenCuttingMonitoring();

focusin


focusout


fullscreenchange


fullscreenerror


gesturechange


gestureend


gesturestart


gotpointercapture


keydown


keyup


lostpointercapture


mousedown


mouseenter


mouseleave


mousemove


mouseout


mouseover


mouseup


MSGestureChange


MSGestureEnd


MSGestureHold


MSGestureStart


MSGestureTap


MSInertiaStart


MSManipulationStateChanged


paste


pointercancel


pointerdown


pointerenter


pointerleave


pointermove


pointerout


pointerover


pointerup


scroll


scrollend


securitypolicyviolation


touchcancel


touchend


touchmove


touchstart


transitioncancel


transitionend


transitionrun


transitionstart


webkitmouseforcechanged


webkitmouseforcedown


webkitmouseforceup


webkitmouseforcewillbegin


wheel