【问题标题】:why does writing the simplest code in html on Chrome not work为什么在 Chrome 上用 html 写最简单的代码不起作用
【发布时间】:2016-12-21 23:38:49
【问题描述】:

例如:

<!doctype html>
<html>
<head>
    <title>Example of confirm()</title>
        <script>
           if (confirm("Want to go to Disneyland?"))
           document.location.href
           =“http://park.hongkongdisneyland.com”;
       </script>             //says this wont work, because of the /<
    </head>               //says this wont work, because of the /<
</html>              //says this wont work, because of the /<

VM43:1 Uncaught SyntaxError: Unexpected token

【问题讨论】:

  • 该代码是正确的。可能错误在其他地方。
  • 这个问题很难解释,但我假设您的 HTML 无效。如果您需要任何有用的反馈,请发布您的 HTML 代码。
  • 还要使用“代码块”来发布代码,否则它真的不可读。
  • 尝试使用正则引号而不是弯引号。
  • 你的报价被抬高了。使用",而不是

标签: javascript html


【解决方案1】:

正如 cHao 所说,你必须确保你使用正确的“”

<!doctype html>
<html>
<head>
    <title>Example of confirm()</title>
        <script>
           if (confirm("Want to go to Disneyland?"))
           document.location.href
           ="http://park.hongkongdisneyland.com"; //This was changed
       </script>
    </head>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-04
    • 2012-05-25
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多