我有两个域 - 我们称它们为 newssite.com 和 app.com。
在 newssite.com/myapp 上,我将插入 app.com 的 iframed 版本。
类似的东西。
当人们点击该 iframe 中的链接时,我希望浏览器中的顶部主 URL 更新,以便人们可以直接链接到它,然后我将在 iframe 中加载正确的 url。
它应该更新为类似 newssite.com/myapp#!app.com/new/link.html 的内容
无论如何我可以做到这一点吗?我不断收到跨域错误..
最佳答案
使用 <base target="_parent" />
在 iframe 的头部,或标签中的相同属性 <a href="doWhatNow" target="_parent">link in iframe</a>
关于javascript - Javascript 中 opener 的跨域更新哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31077781/