Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute 'replaceState' on 'History' <local_URL> cannot be created in a document with origin 'null'

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>
like image 869
Learner Avatar asked Sep 09 '15 13:09

Learner


1 Answers

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>
like image 134
Nishanthi Grashia Avatar answered Nov 03 '22 14:11

Nishanthi Grashia