<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script type="text/javascript"> var time; window.onload = function(){ time = setTimeout("show()",2000);//设置两秒后开始调用show方法,并用time记住setTimeout的返回值 } function show(){ var img1 = document.getElementById("img1"); img1.style.display = "block";//将图片设置为显示 clearTimeout(time);//清除原来的setTimeout的设置,可以不写,因为下面有重新赋值 time = window.setTimeout("hide()",2000); //两秒后调用hide()方法隐藏图片,并将time重新赋值。 } function hide(){ var img1 = document.getElementById("img1"); img1.style.display = "none";//将图片设置为隐藏 clearTimeout(time);//可有可无 time = window.setTimeout("show()",2000);//两秒后调用show()方法显示图片,并将time重新赋值 } </script> </head> <body> <img src="img3.jpg" id="img1" id="img1"> </body> </html>
javascript—广告弹窗
猜你喜欢
转载自www.cnblogs.com/wwww2/p/12106621.html
今日推荐
周排行