How to override window.location in Firefox?

☆樱花仙子☆ 提交于 2020-01-11 10:42:14

问题


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.



来源:https://stackoverflow.com/questions/7985874/how-to-override-window-location-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!