此脚本会旋转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>
答案 0 :(得分:0)
这是一个简单的计时器功能。您需要做的只是将代码放入切换弹出标签
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;
}
}