如下代码:
<script type="text/javascript">
function doSent1(){
var count=0;
var customDates={
startDates:"",
endingDates:"",
startToEnding:""
};
if(count==0){
window.returnValue=customDates;
window.close();
var ifFieldNull = checkNullField();
}
function checkNullField(){
alert("执行了!");
}
</script >
在函数doSent1()的函数体内,虽然变量定义操作var ifFieldNull = checkNullField();写在window.close();之后,但是事实上count==0的条件成立时,是先执行了checkNullField();操作,所以还是会弹出alert("执行了!");,只是因为随后窗口被关掉掉了,所以之前的弹窗只是一闪而过,很难看到,但是还是能听到弹窗时的声音。