日期:2014-05-16  浏览次数:20315 次

javascript中延时弹出窗口问题
<script type="text/javascript">
 function showWindow1(){
setTimeout(alert("hehe"),10000);
}
</script>
我写的这行代码,目的是为了当触发这个动作时,alert窗口能延时10秒才弹出,但是我运行时发现这并不是延迟10秒弹出,而是一触发就弹出了alert窗口,这是什么原因啊?该怎么改这个代码才能让alert窗口延迟10秒弹出啊?
JavaScript 函数

------解决方案--------------------
 function showWindow1(){
setTimeout(function(){  alert("hehe")  } ,10000);

}
------解决方案--------------------

<script type="text/javascript">
setTimeout(function(){
alert('hello world');
},1200);
</script>