谁有显示10秒就自动消失的广告代码啊
谁有显示10秒就自动消失的广告代码啊 setTimeout 这个请百度吧 长时间没写js有点生疏,代码如下<html>
<head>
<title> 广告显示10秒,每天一次 </title>
<style>
#ad{
width:400px;
height:400px;
line-height:400px;
text-align:center;
font-size:20px;
background:pink;
border:1px solid #ccc;
font-family: sans-serif;
}
</style>
</head>
<body>
<div id="ad">
开发找sunshow
联系 QQ6764800
</div>
</body>
<script type="text/javascript">
/*
每24小时显示1次ad,时间10秒
by sunshow
*/
let cookie_key="ads"; //唯一值,不同页面设置不同的key值
let cookie_value="abc"; // 键值
let div_ID="ad";//所需要隐藏的DIV ID
let _time=10;//显示时间(秒);
function _setCookie(cookie_key,cookie_value) {
let _day = new Date();
_day.setTime(_day.getTime()+24 * 60 * 60 * 1000);
document.cookie =cookie_key+'='+cookie_value+';expires='+_day.toGMTString();
}
function _show(div_ID){
document.getElementById(div_ID).style.display="block";
}
function _hide(div_ID){
document.getElementById(div_ID).style.display="none";
}
function adController(cookie_key,cookie_value,div_ID){
_setCookie(cookie_key,cookie_value);
_hide(div_ID);
}
function _display(cookie_key,cookie_value,div_ID,_time){
let time=_time*900;
if (!document.cookie.includes(cookie_key+'='+cookie_value)) {
console.log(time);
setTimeout("adController(cookie_key,cookie_value,div_ID)",time);
} else {
_hide(div_ID);
}
}
window.onload = _display(cookie_key,cookie_value,div_ID,_time);
</script>
</html>
会写代码的都是高手 这是高手
页:
[1]