31
votes

I really don't get this chrome error:

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

In Edge, Firefox and IE no errors.

I use jquery 1.11.1 and jquery mobile 1.4.5.

This is my index file:

<!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>

Any help much appreciated!

3
Without your Javascript code, we won't be able to help you much... - D4V1D
@D4V1D I didn't change jquery i just load it. - olivier
Are you running a webserver (locally or not)? - A. Wolff
@A.Wolff No i don't run one. It worked before without one. Should i use one? - olivier
@olivier Ya you should use one, sounds like a change in new update chrome security feature (maybe to fix a security hole, who knows?). Test it running a local server, if it fixes your issue, don't hesitate to post an answer here. If not, don't hesitate to comment - A. Wolff

3 Answers

62
votes

Add this:

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

Just before jquery.mobile-1.4.5.min.js

That works with Android WebViewClient and Chrome on Windows.

25
votes

The Solution for me was that i have to run a webserver. It's a new chrome security feature and wont be changed according Chromium Bug Post.

Thanks to A. Wolff!

0
votes

This can also be caused by Turbolinks (HTML pushState) when working with a local HTML file.