//结构部分
<div id="pn">
<h1>欢迎来到双哥网</h1>
<h2>大幅的广告</h2>
</div>
<div class="content">
双哥网欢迎你<br/>
正文部分
</div>
//交互部分
<script type="text/javascript">
var H = 0;
function addH () {
if(H < 300) { //假设广告的高度为300
H += 5;
document.getElementById("pn").style.height = H + "px";
}else {
return;
}
setTimeout("addH()", 30);
}
window.onload = function() {
addH(); //广告展开
setTimeout("subH()", 3000); //3秒后广告隐藏
}
function subH () {
if(H > 0){
H -= 5;
document.getElementById("pn").style.height = H + "px";
}else {
document.getElementById("pn").style.display = "none";
return;
}
setTimeout("subH()", 30)
}
</script>
时间: 2024-10-05 17:23:35