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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -