2015-09-08 21 views
31

我真的不明白这个铬错误:未捕获的SecurityError:未能执行“历史记录”“replaceState:不能与起源“空”的文档中创建

Uncaught SecurityError: Failed to execute 'replaceState' on 'History': cannot be created in a document with origin 'null'

在边缘,Firefox和IE没有错误。

我使用jquery 1.11.1和jquery mobile 1.4.5。

这是我的索引文件:

<!DOCTYPE html> 
<html> 
<head> 

    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <link rel="stylesheet" href="css/xy.min.css" /> 
    <link rel="stylesheet" href="css/jquery.mobile.icons.min.css" /> 
    <link rel="stylesheet" href="css/jquery.mobile.structure-1.4.5.min.css" /> 

    <title></title> 

</head> 

<body> 
    <div data-role="page"> 
     <div data-role="header" data-add-back-btn="true"> 
      <p align="center">Test</p> 
     </div> 

     <ul data-role="listview" data-filter="true" data-filter-placeholder="Kategorie suchen" data-inset="true" data-count-theme="b"> 
      <li><a href="assets/beck/index.html" data-rel"dialog" rel ="external">Bäckereien </a></li> 
     </ul> 

    </div> 
    <script src="js/jquery-1.11.1.min.js"></script> 
    <script src="js/jquery.mobile-1.4.5.min.js"></script> 
</body> 

</html> 

任何帮助,非常感谢!

+0

没有你的Javascript代码,我们将无法帮助你太多... – D4V1D

+0

@ D4V1D我没有改变jquery,我只是加载它。 – olivier

+0

你是否运行网络服务器(本地或不是)? –

回答

61

补充一点:

<script> 
    $(document).bind('mobileinit',function(){ 
     $.mobile.changePage.defaults.changeHash = false; 
     $.mobile.hashListeningEnabled = false; 
     $.mobile.pushStateEnabled = false; 
    }); 
</script> 

就在jquery.mobile-1.4.5.min.js

了Android WebViewClient和Chrome在Windows上运行。

+0

感谢这个脚本。我担心我的Android应用程序将变得无用(仅使用Webview和本地文件) – AxelH

+2

好几个月的工作后,我可以与这种感觉联系起来。希望他们不要改变别的。 – eFMer

+6

我发现我只需要'$ .mobile.pushStateEnabled = false;'脚本 – BluGeni

25

对我来说,解决方案是我必须运行一个网络服务器。这是一个新的Chrome安全功能,不会根据Chromium Bug Post进行更改。

感谢A.沃尔夫!

+1

它说这个bug不会被修复?我发现以下问题仍然存在 - https://code.google.com/p/chromium/issues/detail?id=528681 – zumek

+1

当我在Firefox中运行它时,我的问题得到解决.. :-) –

+2

最快和最简单的方法是: python -m SimpleHTTPServer 8080 –

0

当使用本地HTML文件时,这也可能是由Turbolinks(HTML pushState)造成的。

相关问题