这里有一个是关于VBScript的疑问,请问该怎么解决?

<html>
<head>
<script type="text/vbscript">
function greeting()
i=hour(time)
if i < 10 then
document/write("Good morning!")
else
document/write("Have a nice day!")
end if
end 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>
显示出来就是:我喜欢的颜色是:蓝色
并没有倒过来,不明白为什么?

慕容708150
浏览 311回答 2
2回答

慕桂英546537

在执行“document.write ("Look at:" & greeting())”这句话的时候,括号中的"Look at:" & greeting()被看做是一个表达式,表达式中含有函数,系统在显示这个表达式之前,去执行了函数。也就是首先显示了greeting()函数中的内容,执行完函数后由于函数没有返回值,于是就写了一个Look at:。

慕莱坞森

改成这样就可以了:if s = mm thenalert("密码正确")elsealert("密码错误,请重输")end if另外,你的源代码中落下一个loop.
打开App,查看更多内容
随时随地看视频慕课网APP