简体   繁体   English

页面上未检测到JavaScript(history.pushState)

[英]No JavaScript being detected on page (history.pushState)

I was following along with Jeffery Way's history.pushState tutorial on Tuts+ , however I'm not able to get his results. 我一直在关注Jeffery Way 在Tuts +上history.pushState教程 ,但是无法获得他的结果。

Basically, here is my test page: http://leongaban.com/_tuts+/HTML5/ 基本上,这是我的测试页: http : //leongaban.com/_tuts+/HTML5/

With the script at the bottom of the page, the URL is suppose to look like http://leongaban.com/_tuts+/HTML5/page however nothing happens, also in Chrome and Firefox the developer tools are telling me there is no JavaScript on the page? 在页面底部使用脚本,URL看起来像http://leongaban.com/_tuts+/HTML5/page,但是什么也没发生,在Chrome和Firefox中,开发人员工具也告诉我没有JavaScript这一页?

My full markup (same as Jeffery's): 我的完整标记(与Jeffery相同):

<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <title>History – pushState</title>

</head>

<body>

    <ul>
        <li><a href="http://d2o0t5hpnwv4c1.cloudfront.net/2086_get-good-with-php/preview.png" title="Rockable">Rockable</a></li>

        <li><a href="http://tutsplus.s3.amazonaws.com/bestof/bestoftuts.jpg" title="Best">Best of Tuts</a></li>

        <li><a href="http://net.tutsplus.com/wp-content/uploads/2012/06/200x200.png" title="Advanced JS">Advanced JS</a></li>
    </ul>

    <script type="text/javascript">
        history.pushState(
            'Some data'
            'My Page Title'
            'page'
        );
    </script>

    </body>

    </html>


    <!--

    <script>
        history.go(-1); < Go back 1 page
        history.go(2); < Go forward 2 pages
        history.go(0); < Refresh current page
        history.forward(); < Forward 1 page
        history.back(); < Back 1 page
    </script>

    -->

You need to pass commas into that function, to seperate the variables you are passing to pushState 您需要将逗号传递给该函数,以分隔要传递给pushState的变量

 history.pushState(
            'Some data',
            'My Page Title',
            'page'
        );

You need commas! 您需要逗号! I get Uncaught SyntaxError: Unexpected string /_tuts+/HTML5/:31 我收到Uncaught SyntaxError: Unexpected string /_tuts+/HTML5/:31

history.pushState(
    'Some data',
    'My Page Title',
    'page'
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM