子窗口刚刚弹出时大小为宽 100 像素、高 50 像素,然后通过使用 setTimeout()函数或者setinterval()函数让子窗口每隔2毫秒,宽和高都自动增加 5像素,直到子窗口的宽与 500像素时停止。
子窗口是 div 吧
你题目的解答代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
<style type="text/css">
#box {
position: absolute;
left: 200px;
top: 200px;
background-color: #DDD;
border: 1px solid #f00;
display: none;
}
</style>
</head>
<body>
<div id="box"></div>
<input type="button" value="弹出子窗口" onclick="opp();" />
<script type="text/javascript">
var timer;
function opp() {
clearInterval(timer);
var box = document.getElementById("box");
var w = 100, h = 50;
box.style.display = "block";
box.style.width = w+"px";
box.style.height = h+"px";
timer = setInterval(function(){
w += 5;
h += 5;
box.style.width = w+"px";
box.style.height = h+"px";
if (w>=500)
clearInterval(timer);
}, 2);
}
</script>
</body>
</html>
如有帮助,望采纳!谢谢!