Is it possible to disable, or even better, replace with a custom function, window.location
?
This question is related: Disable a built-in function in jav
I don't believe you can reassign window.location
. From MDN:
Summary
Returns a Location object, which contains information about the URL of the document and provides methods for changing that URL. You can also assign to this property to load another URL.
https://developer.mozilla.org/en/DOM/window.location
As it takes a value like a property, how would you "reassign" the object/function to another value? I don't think it's possible due to the property behavior.
try this
var _window = {
location: "myLocation"
};
(function (window) {
console.log(window.location);
}(_window));