JS定时广告的隐藏和显示;

版权声明:本站所提供的文章资讯、软件资源、素材源码等内容均为本作者提供、网友推荐、互联网整理而来(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考,如有侵犯您的版权,请联系我,本作者将在三个工作日内改正。 https://blog.csdn.net/weixin_42323802/article/details/82795368

 定时广告的隐藏和显示;


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Demo03</title>
    <script type="text/javascript">
        var time;
        window.onload = function() {
            time = window.setInterval("show()", 1000);
        }
        // 显示广告的方法
        function show() {
            // 获得广告的div元素
            var adDiv = document.getElementById("pic");
            adDiv.style.display = "block";
            window.clearInterval(time); // 清空掉之前设置的定时
            time = window.setInterval("hide()", 1000); // 重新再设置一个定时
        }
        // 隐藏广告的方法
        function hide() {
            // 获得广告的div元素
            var adDiv = document.getElementById("pic");
            adDiv.style.display = "none";
            window.clearInterval(time); // 清空掉之前设置的定时
        }
    </script>
</head>
<body>
<img src="../../img/3.jpg" height="50%" width="70%" id="pic" style="display: none"/>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_42323802/article/details/82795368