How to quickly find out what the events of an element of a web page have done?

for example, I want to find out which functions are executed when a web page is triggered by a shutdown event. How can I find out this quickly? Does chrome"s developer tools provide this kind of functionality? (the web page is someone else"s, not my own)


the actions you usually do when you exit a web page are usually tied to beforeunload or unload events, such as the following way of writing

window.onbeforeunload = function (e) {
  e = e || window.event;

  // IE8Firefox 4
  if (e) {
    e.returnValue = '';
  }

  // Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
  return '';
};

remarks (Source MDN): when the string returned by the event (the value of the event.returnValue set beforehand) is not null or undefined, the pop-up confirmation window allows the user to choose whether to close the current page or not. Some browsers display the string returned by this event on the pop-up window. Starting with Firefox 4, Chrome 51, Opera 38, and Safari 9.1, generic confirmation information replaces the string returned by the event. For example, Firefox will say, "this page asks you to confirm that you are leaving-the data you entered may not be saved."

then, open the Chrome developer tool, select the body element, and then display its style information (Styles), by default. We select Event Listeners, to find beforeunload (see unload if tied to unload) event, under which are all the corresponding handlers.

clipboard.png

Menu