我想利用javascript制作一个在网页右下角出现的浮动窗口,窗口里面是2分钟的倒计时,时间一到就转到另一个
1个回答
展开全部
<!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>无标题文档</title>
<script type="text/javascript">
function foo(){
var s=document.getElementById('m').innerHTML;
if(s==0){document.getElementById('d1').style.display='none'; document.getElementById('d2').style.display='block'; return;}
document.getElementById('m').innerHTML=s-1;
t=setTimeout('foo()',1000);
}
</script>
<body onload="foo()">
<div id="d1" style="position:absolute; right:0px; bottom:0px; border:1px solid #666; width:200px; height:100px; background-color:#FFFFBF; display:block;">第一个窗口,<br />倒计时<span id="m">120</span>秒</div>
<div id="d2" style="position:absolute; right:0px; bottom:0px; border:1px solid #666; width:200px; height:100px; background-color:#FFFFBF; display:none;">第二个窗口</div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function foo(){
var s=document.getElementById('m').innerHTML;
if(s==0){document.getElementById('d1').style.display='none'; document.getElementById('d2').style.display='block'; return;}
document.getElementById('m').innerHTML=s-1;
t=setTimeout('foo()',1000);
}
</script>
<body onload="foo()">
<div id="d1" style="position:absolute; right:0px; bottom:0px; border:1px solid #666; width:200px; height:100px; background-color:#FFFFBF; display:block;">第一个窗口,<br />倒计时<span id="m">120</span>秒</div>
<div id="d2" style="position:absolute; right:0px; bottom:0px; border:1px solid #666; width:200px; height:100px; background-color:#FFFFBF; display:none;">第二个窗口</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询