无法执行'历史记录'上的'replaceState'< local_URL>不能在源文件为'null'的文档中创建 [英] Failed to execute 'replaceState' on 'History' <local_URL> cannot be created in a document with origin 'null'
问题描述
点击页面导航到另一个页面 - 适用于Firefox,但不适用于Chrome。
/ b>错误显示:
未捕获SecurityError:无法执行'replaceState'on '历史记录':
无法在源文件为'null'的文档中创建URL为'file:/// C:/Users/athite/Desktop/DEMO/page.html'的历史状态对象。 **
以下是我的代码:
<!DOCTYPE html>
< html>
< head>
< meta name =viewportcontent =width = device-width,initial-scale = 1>
< link rel =stylesheethref =http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css>
< script src =http://code.jquery.com/jquery-1.11.3.min.js>< / script>
< script src =http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js>< / script>
< / head>
< body>
< div data-role =pageid =pageone>
< div data-role =header>
< h1>欢迎使用我的主页< / h1>
< / div>
< div data-role =mainclass =ui-content>
< p>点击链接查看幻灯片效果。< / p>
< a href =#pagetwodata-transition =slide>滑动页面二< / a>
< / div>
< div data-role =footer>
< h1>页脚文字< / h1>
< / div>
< / div>
< div data-role =pageid =pagetwo>
< div data-role =header>
< h1>欢迎使用我的主页< / h1>
< / div>
< div data-role =mainclass =ui-content>
< p>点击链接返回。 < / p为H.
< a href =#pageonedata-transition =slidedata-direction =reverse>前往第一页< / a>
< / div>
< div data-role =footer>
< h1>页脚文字< / h1>
< / div>
< / div>
< / body>
< / html>
问题发生在 jquery.mobile-1.4.5.min.js:3
解决方案:
在导入前添加以下脚本:
< script> ;
$(document).bind('mobileinit',function(){
$ .mobile.pushStateEnabled = false;
});
< / script>
< script type =text / javascriptsrc =js / jquery.mobile-1.4.5.min.js>< / script>
I am creating a page for the transition.
Clicking on the page to navigate to another page - works on Firefox, but it doesn't on Chrome.
Error is showing :
Uncaught SecurityError: Failed to execute 'replaceState' on 'History':
A history state object with URL 'file:///C:/Users/athite/Desktop/DEMO/page.html' cannot be created in a document with origin 'null'.**
Here is my code:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Click on the link to see the slide effect.</p>
<a href="#pagetwo" data-transition="slide">Slide to Page Two</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Click on the link to go back. </p>
<a href="#pageone" data-transition="slide" data-direction="reverse">Go to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
The issue occured in jquery.mobile-1.4.5.min.js:3
Solution:
Add this script before import as follows:
<script>
$(document).bind('mobileinit',function(){
$.mobile.pushStateEnabled = false;
});
</script>
<script type="text/javascript" src="js/jquery.mobile-1.4.5.min.js"></script>
这篇关于无法执行'历史记录'上的'replaceState'< local_URL>不能在源文件为'null'的文档中创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!