How to determine if an annual overload was caused by clicking a link in Chrome
source link: https://www.codesd.com/item/how-to-determine-if-an-annual-overload-was-caused-by-clicking-a-link-in-chrome.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to determine if an annual overload was caused by clicking a link in Chrome
The problem is as follows.
onbeforeunload
works like a charm in Firefox and has e.explicitOriginalTarget.activeElement
that shows what element has been clicked to cause it.
window.onbeforeunload = function(e){
if (e.explicitOriginalTarget.activeElement){
return;
}
In Chrome the 'e
' object looks identical when you close the window or click the link. Is there any way to determine the target in chrome?
No. The target of the event is the window or document, not the link. Unlike Firefox, Chrome provides no helpful bonus properties on the event object. Your best bet may be to have an click event handler on the body that examines the event target to see if it's a link, but that's not foolproof: the link may have its own click event handler that prevents the default action, or the user may follow the link using the keyboard, in which case no click event will be fired.
Recommend
-
84
Pixel 2 high pitch frequency sound and clicking1 Recommended Answer****Update 10/27/17: I have received two phones wh...
-
42
“Dear @AppleSupport, we noticed a *HUGE* security issue at MacOS High Sierra. Anyone can login as "root" with empty password after clicking on login button several times. Are you aware of it @Apple?”
-
9
Matthew Miner Methodic: Run Functions by Clicking a Button June 17, 2017 Ages ago I bui...
-
3
how to display different DIV parts by clicking different & lt; li & gt; Links in the same JSP? advertisements I want to display a diff...
-
6
js;dr = JavaScript required; Didn’t Read. Pages that are empty without JS: dead to history (archive-org), unreliable for search results (despite any search engine claims of JS support, check it yourself), and thus ignorable. No need to waste tim...
-
6
22261 – Clicking on a non-text input element does not give it focus WebKit Bugzilla Bug 22261: Clicking on a non-text input element does not give it focus ...
-
5
How to turn on PhotoSwipe without clicking? advertisements I use the the mobile PhotoSwipe gallery. M...
-
4
Prevent from clicking on div advertisements I have a div container, which holds several "rows" of data, with each item in the list in it's own...
-
4
Define the session by clicking on the html link? advertisements I have searched and tested different solutions all day without luck. In the be...
-
4
Simulate clicking a button in another window in C # advertisements I'd like to close a dialog that pops up automatically, but I'm having some...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK