You get a bonus - 1 coin for daily activity. Now you have 1 coin

how do you detect a browser tab being closed in javascript while excluding navigation within the site?

Practice




how do you detect a browser tab being closed in javascript while excluding navigation within the site?
that is, exclude clicks on links?

$(document).ready(function () {

$('a').each(function (index, value) {
$(this).click(function () {
window.onbeforeunload = null;
});
});
$('div').each(function (index, value) {
$(this).click(function () {
window.onbeforeunload = null;
});
});
window.onbeforeunload = function (e) {
return ' click STAY ON THE PAGE! ';


};

});

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone