当前位置: 代码迷 >> JavaScript >> javascript中延时弹出窗口有关问题
  详细解决方案

javascript中延时弹出窗口有关问题

热度:139   发布时间:2013-08-09 15:16:24.0
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>
  相关解决方案