这个脚本旋转5个弹出式标签,为每个网页手动刷新显示一个弹出式标签。我希望脚本自动旋转一个弹出式标签每60秒。
如果一个天才能做到,我将非常感谢他。
问候
<script language="JavaScript">
<!--
var frequencyCap = 12;
function setCookie(cookieName,cookieValue, expirehours) {
if (frequencyCap > 0) {
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 10000 * frequencyCap);
document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
} else {
document.cookie = cookieName+"="+escape(cookieValue);
}
}
function ReadCookie(cookieName) {
var theCookie=""+document.cookie;
var ind=theCookie.indexOf(cookieName);
if (ind==-1 || cookieName=="") return "";
var ind1=theCookie.indexOf(';',ind);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}
if (ReadCookie('cookie1') != '1') {
setCookie('cookie1','1', frequencyCap);
document.write("TAG POPUP-1");
}else if (ReadCookie('cookie2') != '1') {
setCookie('cookie2','1', frequencyCap);
document.write("TAG POPUP-2");
}else if (ReadCookie('cookie3') != '1') {
setCookie('cookie3','1', frequencyCap);
document.write("TAG POPUP-3");
}else if (ReadCookie('cookie4') != '1') {
setCookie('cookie4','1', frequencyCap);
document.write("TAG POPUP-4");
}else if (ReadCookie('cookie5') != '1') {
setCookie('cookie5','1', frequencyCap);
document.write("TAG POPUP-5");
}
// -->
</script> 发布于 2017-08-09 09:36:49
下面是一个简单的计时器函数。您所需要做的就是在代码中切换弹出标记
var timer = setInterval(rotate, 60000);
var idx = 0;
function rotate() {
if (idx++ < 5) {
//Insert code to switch popup tags
document.getElementById("demo").innerHTML = "Index: " + idx;
// ^ demo of timer working
if (idx >= 5)
idx = 0;
}
}https://stackoverflow.com/questions/45580200
复制相似问题