HTML5 push/replaceState and the <base> tag causes security exception

纵然是瞬间 提交于 2019-12-05 03:16:33

It is not a bug, you are violating the Same origin policy. "" is a relative URL which will be resolved to 'http://x.com/' since you used the <base> tag. http://x.com is a different domain from where the page is hosted which is why doing this runs afoul of the same origin policy.

Using an absolute URL that points to a resource on http://test.x.com/ in your history.pushState() call should fix this:

history.pushState({}, "", "http://test.x.com/");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!