<学习笔记>浏览器跨域报错:cannot be created in a document with origin 'null'

来源:互联网 发布:58同城 淘宝客服 骗局 编辑:程序博客网 时间:2024/04/29 14:38


报错:Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL'file:///E:/Mars/JQuery-Mobile-Slide-Menu-master/index.html' cannot be created in a document with origin 'null'.


问题原因:跨域。


解决方案:

1、先打开浏览器再打开项目页面;

2、在引用“jquery.mobile.js“前添加如下代码:

    <script><span style="white-space:pre"></span>$(document).bind('mobileinit',function(){        $.mobile.pushStateEnabled = false;      });    </script>    <script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>


0 0
原创粉丝点击