最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Failed to execute 'replaceState' on 'History' <local_URL> cannot be c

programmeradmin9浏览0评论

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=".4.5/jquery.mobile-1.4.5.min.css">
<script src=".11.3.min.js"></script> 
<script src=".4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>

<div data-role="page" id="pageone">
  <div data-role="header">
    <h1>Wele 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>Wele 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>

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./mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery./jquery-1.11.3.min.js"></script> 
<script src="http://code.jquery./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>Wele 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>Wele 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>
Share Improve this question edited Sep 9, 2015 at 14:07 Paul Roub 36.4k27 gold badges85 silver badges94 bronze badges asked Sep 9, 2015 at 13:43 LearnerLearner 1651 gold badge1 silver badge13 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 18

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>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论