window.top.location vs window.location

独自空忆成欢 提交于 2020-01-01 11:36:09

问题


how to sync window.top.location and window.location?


回答1:


This is how you set the parent of the frame (top) to the location of the frame document...

top.location = self.location;

Of course, this code must be executed within the iframe, and is succeptible to the Same-Origin Policy.




回答2:


window.top.location is return you to broswer's address bar location even you'r in i-frame or page.. window.location is return location of your current page address in case facebook apps. if you want to top query-string you have to use

alert(window.top.location);

if u want to replace top location then

window.top.location = "http://whatever.com";



来源:https://stackoverflow.com/questions/5354561/window-top-location-vs-window-location

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