<html><head><script type="text/vbscript">function greeting()i=hour(time)if i < 10 thendocument/write("Good morning!")elsedocument/write("Have a nice day!")end ifend function</script></head><body><script type="text/vbscript">document.write ("Look at:" & greeting())</script></body></html>為什么顯示出來是:Have a nice day! Look at:不是應該是:Look at:Have a nice day! 嗎?下面這個就可以按順序顯示<html><head><script type="text/vbscript">function myFunction()myFunction = "藍色"end function</script></head><body><script type="text/vbscript">document.write("我喜歡的顏色是:" & myFunction())</script></body></html>顯示出來就是:我喜歡的顏色是:藍色并沒有倒過來,不明白為什么?
2 回答

慕桂英546537
TA貢獻1848條經驗 獲得超10個贊
在執行“document.write ("Look at:" & greeting())”這句話的時候,括號中的"Look at:" & greeting()被看做是一個表達式,表達式中含有函數,系統在顯示這個表達式之前,去執行了函數。
也就是首先顯示了greeting()函數中的內容,執行完函數后由于函數沒有返回值,于是就寫了一個Look at:。

慕萊塢森
TA貢獻1810條經驗 獲得超4個贊
改成這樣就可以了:
if s = mm then
alert("密碼正確")
else
alert("密碼錯誤,請重輸")
end if
另外,你的源代碼中落下一個loop.
- 2 回答
- 0 關注
- 388 瀏覽
添加回答
舉報
0/150
提交
取消