Is it possible to programmatically catch all events on the page in the browser?

前端 未结 7 487
心在旅途
心在旅途 2020-12-02 08:18

First of all, here is a list of event types that are defined by the W3C standards. (This list is based on the onevent attributes defined in the HTML5 standard. I assume that

相关标签:
7条回答
  • 2020-12-02 08:41

    You can iterate through all properties of dom element and select ones that match /on(.*)/ pattern (for example onclick or onmousemove):

    var events = [];
    for (var property in element) {
        var match = property.match(/^on(.*)/)
        if (match) { 
            events.push(match[1]);
        }
    }
    console.log(events.join(' '))
    
    0 讨论(0)
提交回复
热议问题