javascript - 未捕获的安全错误 : Failed to execute 'replaceState' on 'History' : cannot be created in a document with origin 'null'

标签 javascript jquery google-chrome jquery-mobile

我真的没有得到这个 chrome 错误:

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

在 Edge、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>

非常感谢任何帮助!

最佳答案

添加这个:

<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 和 Windows 上的 Chrome。

关于javascript - 未捕获的安全错误 : Failed to execute 'replaceState' on 'History' : cannot be created in a document with origin 'null' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32453806/

相关文章:

html - 谷歌字体未在 Chrome 中显示

javascript - 在 iframe 中运行函数 | NW.js(节点 webkit)

google-chrome - Chrome 58 不安全 URL 中的数据

html - 空白/有文本时插入符号在文本区域中的不同位置

javascript - 如何使用来自 javascript 的参数运行 cmd.exe

php - 向下钻取行详细信息中的 NaN - DataTables

javascript - 是否可以计算 html 内容在默认缩放屏幕上占用的空间?

javascript - 如何将 workbox-webpack-plugin 与 Nuxt PWA 一起使用

javascript - 使用 JS 和 JQuery 替换 AJAX 中的字符串或 html onload

javascript - 通过 $http.post 方法传递当前日期