How to override [removed] in Firefox?

2019-02-27 04:49发布

问题:

I am trying to override the window.location in Firefox, through the following code and keep getting an error (actually want to prevent the default behavior, but I think that's not relevant) :

    Code : 
    window.__defineGetter__('location', function() {});

    Error
    redeclaration of var location

I started with the suggestions at Programatically disable window.location.reload?, but didn't work.

Thanks in advance, Sunil

回答1:

The location property of Window is non-configurable for security reasons, because some broken things out in the wild base security checks on the value of window.location.toString(), so you can't do this.