为此POPUP添加循环功能,时间为10秒javascript

问题描述:

此脚本旋转5个pop'up标记,为每个网页手动刷新显示一个pop'up。 我希望脚本每60秒自动旋转一个pop'up标签。为此POPUP添加循环功能,时间为10秒javascript

如果有人天才可以使我将非常感激他

问候

<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

'我希望脚本全自动一个pop'up每60 seconds'旋转 - 好,一开始,你需要停止使用'document.write' - 事实上,你应该停止使用它! –

+0

嗨,也许但这是使JavaScript弹出标签工作的唯一方法,你有任何解决方案? –

+0

“javascript popup标签” - 不确定那是什么,你所做的只是在页面上写上“TAG POPUP-#” - 是否有其他一些代码能够对这段文字做些什么?你可以在不使用document.write的情况下实现向页面添加文本 - 除非你真的需要支持Netscape 1.0或Mosaic浏览器,当然 –

下面是一个简单的定时器功能。所有你需要做的就是把你的代码来切换标签弹出

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://jsfiddle.net/3t7nqpg7/1/

+0

谢谢你,我现在测试它,使它工作 –