问答详情
源自:8-5 计时器setTimeout()

为什么执行到num=0时,没有打开新网页

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Untitled Document</title>

<script type="text/javascript">

var num=5;

function five(){

 if(num==0){

  window.open('http://www.imooc.com');

 }

 else{

document.getElementById("button").value=num;

    num=num-1;

     setTimeout("five()",1000);

}}

</script>

</head>

<body>

<input id="button" type="button" onclick="five()" value="倒数五秒进入幕客网" style="color:#C00;width:1000px;background:#0F0">

</body>

</html>


提问者:Beyond_Dream_ 2017-12-27 14:18

个回答

  • qq_听_26
    2017-12-27 17:34:48
    已采纳

    我这边是浏览器阻止了网页打开新窗口,在提示的地方选择始终允许就行了