2010-02-01 20 views
0
<html> 
    <head></head> 
    <body> 
    <script type = "text/javascript"> 
     var x = 5; 
     var y = 8; 
     if (x < 6) 
     { 
     document.write("They are equal"); 
     } 
     else 
     { 
     document.write{"They are NOT equal"); 
     } 
    </script> 
    </body> 
</html> 
+0

在瀏覽器中會顯示出語法錯誤,一個適當的編輯器或JS調試器。也許你想看看Komodo Edit http://www.activestate.com/komodo_edit/和Firefox的Firebug http://getfirebug.com/ – 2010-02-01 19:40:49

+0

也打開腳本調試。 – ChaosPandion 2010-02-01 19:41:47

+1

嘗試JSLint或JavascriptLint,它們將爲您節省大量的時間並解決這些類型的問題 – 2010-02-01 19:43:38

回答

12

我認爲你有一個語法錯誤:

document.write{"They are NOT equal"); 

應該

document.write("They are NOT equal"); 
+0

該死的。我不敢相信15分鐘後我沒有看到這個:(謝謝ChaosPandion! – noobzilla 2010-02-01 19:40:28

+0

@idunno - 我做得更糟:)。 – ChaosPandion 2010-02-01 19:41:23

+1

你應該看看是否可以使用字體編碼來減少這個問題。 – 2010-02-01 21:22:38

相關問題