Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经看到location.href, window.open, window.location, 等进行重定向。
location.href
window.open
window.location
请分别对待1和2问题的答案,并提前致谢。
window.location.href = 'URL';
是改变当前窗口位置的标准实现。
document.location是一个(已弃用但仍然存在)只读字符串属性,由document.url代替。
window.location也会影响框架,
我发现的最好的形式是:
parent.window.location.href
更糟糕的是:
parent.document.URL
我做了一个大规模的浏览器测试,一些罕见的带有几个插件的 IE 在第二种形式中未定义。