Detect Click on Browser

前端 未结 1 1502
有刺的猬
有刺的猬 2020-12-31 22:23

How to detect click (including browser\'s back button) events using javascript?

相关标签:
1条回答
  • 2020-12-31 23:04

    You can detect clicks inside the page with a simple click event handler:

    document.onclick= function(event) {
        // Compensate for IE<9's non-standard event model
        //
        if (event===undefined) event= window.event;
        var target= 'target' in event? event.target : event.srcElement;
    
        alert('clicked on '+target.tagName);
    };
    

    It is impossible for web-page script detect clicks outside the page such as the back button and other browser chrome, for good security reasons. You would have to be part of a browser extension to do this.

    0 讨论(0)
提交回复
热议问题