javascript 浏览器:未捕获的安全错误:无法在“历史”上执行“replaceState”:带有 URL 的历史状态对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32408726/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Browser: Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL
提问by safron6
I just got this error on a on desktop only website which uses an IDE to render the page. It works on FireFox some, but the controls necessary to generate all of the JavaScript is not there as in Chrome. Perhaps I could add a cross compatibility line but I do not know what. The reason why is this strange error I never have had before on the debugger... Please help with resolution.
我刚刚在使用 IDE 呈现页面的仅限桌面的网站上收到此错误。它适用于某些 FireFox,但生成所有 JavaScript 所需的控件不像在 Chrome 中那样存在。也许我可以添加一个交叉兼容性线,但我不知道是什么。原因是我以前在调试器上从未遇到过这个奇怪的错误......请帮助解决。
Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///C:/Users/J/Desktop/Rain_Watch%20Webpage/default.html' cannot be created in a document with origin 'null'.
jquery.min.js:2 Uncaught Error: jHERE already initialized, expected method.
回答by Learner
just tried something similar and I got the same error with Chrome. when I run the code from a webserver works fine.
刚刚尝试了类似的东西,我在 Chrome 上遇到了同样的错误。当我从网络服务器运行代码时工作正常。
create a dir in webapps in tomact put web-inf from root in project dir create a startup file which start page of your project http://localhost:8080//index.jsp
在 tomact 的 webapps 中创建一个目录 将 web-inf 从 root 放在项目目录中创建一个启动文件,该文件是您项目的起始页面 http://localhost:8080//index.jsp
回答by Neha
I am also getting the same error while testing my project on Google Chrome. But it is working on Firefox, Opera and Safari on Mac.
在 Google Chrome 上测试我的项目时,我也遇到了同样的错误。但它适用于 Mac 上的 Firefox、Opera 和 Safari。
If anyone is encountering the same issue, test your project on other broswers.
如果有人遇到同样的问题,请在其他浏览器上测试您的项目。
You can find this issue discussed on ChromeReleases Blog.
您可以在ChromeReleases 博客上找到讨论的这个问题。