javascript - How to remove/reset window.onfocus function? -
this has been driving me nuts.
when load page initiate window.onfocus function:
initializefocusdetecttor: function () { window.onfocus = function () { var options = { usefade: false } $.overwatch.worker.getview("/overwatch/updatewatch", function () { $.overwatch.init(); }, options); } }
however don't want behavior on every page don't know how remove/reset this.
i have tried
window.onfocus = null; window.onfocus = function(){return;}; window.onfocus = "";
but not work
if change use jquery event handling, can remove (e.g. off
).
initializefocusdetecttor: function () { $(window).on('focus.mine', function () { var options = { usefade: false } $.overwatch.worker.getview("/overwatch/updatewatch", function () { $.overwatch.init(); }, options); }); }); // condition - turn off $(window).off('focus.mine');
this example adds custom namespace .mine
event name can target without affecting other code using focus events.
Comments
Post a Comment