Is it possible to overwrite [removed] function with a custom function?

后端 未结 2 1880
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 03:32

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

相关标签:
2条回答
  • 2021-01-02 04:05

    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.

    0 讨论(0)
  • 2021-01-02 04:13

    try this

    var _window = {
           location: "myLocation"
    };
    
    (function (window) {
       console.log(window.location);
    }(_window));
    
    0 讨论(0)
提交回复
热议问题