ReactJS与react-router浏览器历史记录问题

时间:2016-11-03 15:12:14

标签: reactjs react-router browser-history

我有一个reactjs网站,它使用react-router和browserHistory。

今天我发现了一个问题,我不知道如何解决这个问题。 问题是,当我的网站在iframe中打开时,例如在谷歌翻译页面中。每次点击链接时,我网站上的导航都不再有效,它给了我这个错误:

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'https://www.mywebsite.com/page' cannot be created in a document with origin 'https://translate.googleusercontent.com' and URL 'https://translate.googleusercontent.com/translate_c?depth=2&hl=fr&prev=sear….com&sl=en&u=https://www.mywebsite.com/&usg=ALkJrhiWY47c812s4y3W0cS1VDZX0xRNqA'.

有谁知道我怎么能'解决'这个?

顺便说一下,我使用最新版本的Chrome和Firefox(都在Windows上)对此进行了测试

由于

1 个答案:

答案 0 :(得分:1)

这是一种安全设计。你不能推动历史状态跨域。

Mozilla在这里很好地记录了这个限制: https://developer.mozilla.org/en-US/docs/Web/API/History_API

相关问题