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.
如何同步 window.top.location 和 window.location?
这就是您如何将框架 ( top) 的父级设置为框架文档的位置...
top
top.location = self.location;
当然,这段代码必须在 iframe 内执行,并且受同源策略的影响。
即使您在 i-frame 或页面中,window.top.location 也会将您返回到浏览器的地址栏位置。window.location 是您当前页面地址的返回位置,以防 Facebook 应用程序。如果你想置顶查询字符串,你必须使用
alert(window.top.location);
如果你想替换顶部位置
window.top.location = "http://whatever.com";