在Firefox开发人员工具中查看DOM事件('ev'标记事物),如何?

Byz*_*zod 5 javascript firefox events event-listener

Firefox的Inspector可以列出从Firefox 33 连接到特定DOM节点的所有事件监听器.

示例页面:

<!doctype html>
<body>
    <button id="Btn">Test</button>
    <script>
        function TestEventListener(e){
            console.log("handle event");
        }
        var btn = document.querySelector("#Btn");
        if(btn){
            btn.addEventListener("click",TestEventListener,false);
        }
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

然后按F12并选择Inspector,单击ev旁边的小标签<button>. 在此输入图像描述

  • Firefox是如何做到的?
  • Firefox addEventListener从一开始就被修改了吗?
  • 这可以用原生Javascript完成吗?

    像这样:

    function GetDOMEventList(node){
        var listenerFunctionsList = [];
        [Magic Moves]
        return listenerFunctionsList; // [func1, func2, func3...]
    }
    
    Run Code Online (Sandbox Code Playgroud)