JS公告跳转

先看效果

上代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			#clock {
				border: 0px solid red;
				width: 200px;
				height: 20px;
			}
			
			.p {
				font-size: 50px;
			}
			.b {
				color: darkorange;
			}
		</style>
	</head>
	<body style="background-color: azure;">
		<br><br><br><br><br>
		<div align="center">
			<p class="p b">----------- 公告 -----------</p> <br>
			<p class="p">
				(本系统)网站域名将于2018年12月13日起变更为
				<a href="https://blog.csdn.net/lxb1113220682" style="color: cornflowerblue;">https://blog.csdn.net/lxb1113220682</a>,原域名https://blog.csdn.net/lxb111322068将停止使用,特此公告。
				<br><br>
				<span id="clock" style="color: red;">20</span>秒后将跳转到<a href="https://blog.csdn.net/lxb1113220682" style="color: cornflowerblue;">https://blog.csdn.net/lxb1113220682</a>首页
				
			</p>
		</div>
		
		

	</body>
	
	<script type="text/javascript">
		
		function showTime(){
			var a = document.getElementById("clock").innerHTML;
			var b = a-1;
			var idClock = document.getElementById("clock");
			idClock.innerHTML = b;
			if(b == 0){
				window.location.href="https://blog.csdn.net/lxb1113220682";
			}
			
		}
		// 定时调用该方法
		setInterval("showTime()", 1000);
		
		
	</script>
	
</html>

猜你喜欢

转载自blog.csdn.net/lxb1113220682/article/details/85010371
今日推荐