javascript - Programmatically disable window.location.reload? -


is there way override default behavior of window.location.reload - making no-op, debugging purposes?

the problem reason, location.reload not writable property in firefox , chrome. here's crazy way came override (and others) in browsers. uses non-standard .__definegetter__() method, in part bypass magic of window.location = "/home.html" interfering.

var _location = location; __definegetter__('location', function() {     var s = new string(_location);     for(i in _location) (function(i) {         s.__definegetter__(i, function() {             return typeof _location[i] == 'function' ? function(){} : _location[i];         });         s.__definesetter__(i, function(){});     })(i);     return s; }); __definesetter__('location', function(){}); 

the resulting mock object should prevent function call (including .reload) or assignment (setting .href) taking effect. alternatively, can limit testing ie, safari, , opera, in .reload writable.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -