有人可以讓我知道下面的JavaScript有什麼問題。它假設顯示時間和日期,但只顯示HTML標題。我從一本javascript書中獲得了這本書,用於學習,我認爲它現在可能會變老,而事情可能已經改變,或者我犯了一個錯誤。第一次需要javascript幫助
<html>
<head><title>Date time</title></head>
<body>
<h1> Time and Date </h1>
<script LANGUAGE="JavaScript" type="textjavascript">
\t now = new Date();
\t localtime = now.toString();
\t utctime = now.toGMTString();
\t document.write ("<b> local time: </b>" + localtime + "<BR>");
\t document.write ("<b> UTC time: </b>" + utctime +);
\t
\t document.write("Hello World!");
</script>
</body>
</html>
感謝您的幫助
試試這個:'now = new Date(); localtime = now.toString(); utctime = now.toGMTString(); document.write(「當地時間:」+ localtime +「
」); 文件撰寫( 「UTC時間: 」+ utctime);'' – Rayon
文件撰寫(「 UTC時間:」 + utctime +);',有一個不必要的'+'晃來晃去這裏 – Ramanlfc
這並不工作無論是。我看不出你寫的東西和我已有的東西有什麼不同。我將文檔保存爲.html並上傳到我的服務器,我認爲這是正確的。 – user2669997