Yes, accessing parent page's URL is not allowed if the iframe and the
main page are not in the same (sub)domain. However, if you just need
URL of the main page (i.e. the browser URL), you can try this
var url = (window.location != window.parent.location) ? document.referrer: document.location;
# 1 楼答案
如果您试图从iFrame获取主页的url,则只有当它们位于同一子域中时才有可能
Access parent URL from iframe