2016-08-15 30 views
-6

如剛:爲什麼寫簡單的代碼的HTML Chrome上無法正常工作

<!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未捕獲的SyntaxError:意外的標記<

+1

該代碼正確。可能錯誤在別的地方。 – ema

+0

這個問題很難解釋,但我假設你的HTML無效。如果您需要任何有用的反饋,請發佈您的HTML代碼。 –

+0

也使用「代碼塊」來發布代碼,否則它真的不可讀。 – ofca

回答

0

由於超說,你一定要確保你使用正確的「

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

相關問題