window.userInteractionTimeout = null;
window.userInteractionInHTMLArea = false;
window.onBrowserHistoryButtonClicked = null;
$(document).ready(function () {
$(document).mousedown(function () {
clearTimeout(window.userInteractionTimeout);
window.userInteractionInHTMLArea = true;
window.userInteractionTimeout = setTimeout(function () {
window.userInteractionInHTMLArea = false;
}, 500);
});
$(document).keydown(function () {
clearTimeout(window.userInteractionTimeout);
window.userInteractionInHTMLArea = true;
window.userInteractionTimeout = setTimeout(function () {
window.userInteractionInHTMLArea = false;
}, 500);
});
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
if (!window.userInteractionInHTMLArea) {
}
if(window.onBrowserHistoryButtonClicked ){
window.onBrowserHistoryButtonClicked ();
}
});
}
});
Varun source
share