我寫上nodepad ++ javascript代碼,我在初級水平,僅編寫這些代碼JavaScript代碼不顯示我的期望輸出
<html>
<body>
<script type="text/javascript">
var d=new Date();
var time=d.getHours();
if(time<10)
{
document.write("<b> good morning </b>");
}
else
{
document.write ("<b> good afternoon </b>");
}
</script>
</body>
</html>
然後從編輯nodepad ++,我點擊谷歌瀏覽器上運行,但得到只有這個
<html>
<body>
<script type="text/javascript">
var d=new Date();
var time=d.getHours();
if(time<10)
{
document.write("<b> good morning </b>");
}
else
{
document.write ("<b> good afternoon </b>");
}
</script>
</body>
</html>
代碼的副本,而不是結果,爲什麼?
你用'htm'或'html'擴展名保存了嗎? – alex 2012-03-17 11:41:17