SecurityError:操作不安全 - window.history.pushState() [英] SecurityError: The operation is insecure - window.history.pushState()
问题描述
在Firefox的控制台中出现这个错误: SecurityError:操作不安全
,有罪是HTML5功能: window.history.pushState ()
当我尝试使用AJAX加载某些内容时。它应该加载一些数据,但Javascript停止执行时出错。
我想知道为什么会发生这种情况。这是一些服务器配置错误吗?任何帮助,将不胜感激。
更新:是的,这是一个服务器错误,域名不匹配: http://en.wikipedia.org/wiki/Same-origin_policy
确保您遵循同源政策。这意味着相同的域名,相同的子域名,相同的协议(http vs https)和相同的端口。
编辑:作为@ robertc在他的评论中恰当地指出,当起源 I'm getting this error in Firefox's Console: I'm wondering why this may be happening. Is this some server misconfiguration? Any help would be appreciated. UPDATE: Yes, it was a server error with domain name not matching: http://en.wikipedia.org/wiki/Same-origin_policy Make sure you are following the Same Origin Policy. This means same domain, same subdomain, same protocol (http vs https) and same port. How does pushState protect against potential content forgeries? EDIT: As @robertc aptly pointed out in his comment, some browsers actually implement slightly different security policies when the origin is 这篇关于SecurityError:操作不安全 - window.history.pushState()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! file:///
时,一些浏览器实际上实施了稍微不同的安全策略。更何况,当页面期望它是从一个不同的来源运行时(以及您的 c>),在使用
file://在本地进行测试时,您可能会遇到问题。 pushState
假定生产源方案,而不是本地主机方案)SecurityError: The operation is insecure
and the guilty is HTML5 feature: window.history.pushState()
when I try to load something with AJAX. It is supposed to load some data but Javascript stops executing on error.file:///
. Not to mention you can encounter problems when testing locally with file:///
when the page expects it is running from a different origin (and so your pushState
assumes production origin scenarios, not localhost scenarios)