1.文字推荐位200元/年,需要联系QQ924994768

2.文字推荐广告位,帮你推广你的产品

3.文字推荐广告位,可以加粗、加颜色

打开手机浏览器,都是一个几秒的开屏广告,带有倒计时,一般为10秒,时间到了广告窗口自动关闭。不喜欢的话可以点击跳过。用JavaScript就可以实现定时关闭的广告,再加上倒计时效果和实现跳过的代码。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>定时关闭的广告</title>
		<style type="text/css">
			.main img {
				width: 100%;
			}
			.adv {
				position: absolute;
				z-index: 9;
				width: 616px;
				height: 395px;
				top: 0;
				left: 0;
				bottom: 0;
				right: 0;
				margin: auto;
			}

			.adv .right {
				position: absolute;
				right:0;
				top:10px;
				font-size: 14px;
				color:#fff;
				cursor: pointer;
				background-color: #333;
				border-radius: 10px;
				width: 80px;
				height: 30px;
				line-height: 30px;
				text-align: center;
			}
		</style>
	</head>
	<body>
		<div class="main">
			<img src="images/ad.png">
		</div>
		<div class="adv">
			<div class="right">
				<span id="counting">5</span>秒跳过
			</div>
			<div><img src="images/adv.png" ></div>
		</div>
			<script>
			function closeAdv() { //关闭广告窗口
				document.querySelector('.adv').style.display = "none";
			}
			//点击跳过,关闭广告
			var skip = document.querySelector('.right');	
			skip.addEventListener('click',closeAdv)
			//倒计时关闭广告
			var seconds = 5;               //秒数
			var count = setInterval(countDown, 1000);
			function countDown() {  			//倒计时函数
				seconds--;
				if (seconds == 0) {
					closeAdv();
					clearInterval(count);
				}else{
				document.querySelector("#counting").innerText = seconds;
			  }
			}
		</script>
	</body>
</html>

 

相关文章 8

1

用自定义表单为dedebiz网站制作一个留言板的方法: 3个月前

用自定义表单为dedebiz网站制作一个留言板的方法:...

2

Table ‘xxx’ is marked as crashed and should be repaired数据库MySQL错误解决方法参考 3个月前

最近个人网站不知道为什么无法进入后台,重启服务器后登陆网站后台查看栏目内容时,显示“Table ‘xxx" is marked as crashed and should be repair...

3

dedebiz修改搜索结果页关键字加粗标红或改成自己想要格式的方法 11个月前

dedebiz修改搜索结果页关键字加粗标红或改成自己想要格式的方法: /system/archive目录下searchview.class.php文件, 找到(大约304行) $fstr = str_i...

4

dedebiz文章列表排序方法汇总 1年前

dedebiz文章列表排序方法汇总 1.按点击量(文章阅读量)排序(orderby=hot 或 orderby=click),网站热门文章排序 2.随机排序 orderby=rand 用来随机抽...

5

在局域网内进行内部访问网站的方法 1年前

在局域网内进行内部访问网站的方法: 在同一个网络里或者说用的是同一个路由器,电脑一(win10系统,ip:192.168.8.158)用网线连接,电脑...

6

dedehiz首页调用最新评论的常用方法。 1年前

dedehiz首页调用最新评论的常用方法。 {dede:feedback row='5' titlelen='24' infolen='80'}span style="font-size:12px"smalla href="#" rel="nofollow" class="username"[field:...

7

dedebiz批量替换⽂章标题、正⽂内容关键词⽅法介绍:站长在采集⽂章或者复制别⼈⽂章 1年前

dedebiz批量替换⽂章标题、正⽂内容关键词⽅法介绍:站长在采集⽂章或者复制别⼈⽂章后,需要批量修改⽂章标题、关键词、正⽂、作者、...

8

dedebiz的arclist调用副栏目的文章的方法: 1年前

dedebiz的arclist调用副栏目的文章的方法: 打开/taglib/arclist.lib.php,查找以下代码 if($CrossID=='') $orwheres[] = ' arc.typeid IN ('.GetSonIds($typeid).')';els...