如何让我的 jquery 横幅在页面刷新时是随机的,它上面有一个计时器,所以横幅每 23 秒左右更改一次,而无需重新加载页面。
然而,相同的横幅会在开始时出现,所以我认为它可以通过随机页面重新加载 jquery 来修复。
这是它工作正常的代码,只需要在页面重新加载时也刷新横幅。
我尝试了很多选择,但找不到解决方案。
谢谢。
<script type='text/javascript'>
var imgs1 = new Array('https://paidtoclick.ca/bann/ani.gif','https://paidtoclick.ca/bann/247bux.gif','https://paidtoclick.ca/bann/brab.gif ','https://paidtoclick.ca/bann/CHP.gif','https://paidtoclick.ca/bann/Deft.gif','https://paidtoclick.ca/bann/heard.gif','https://paidtoclick.ca/bann/hg1.gif','https://paidtoclick.ca/bann/Hope.gif','https://paidtoclick.ca/bann/lon.jpg','https://paidtoclick.ca/bann/MZJ.gif','https://paidtoclick.ca/bann/oxj.gif','https://paidtoclick.ca/bann/play.jpg','https://paidtoclick.ca/bann/hg2.gif','https://paidtoclick.ca/bann/z8.gif');
var lnks1 = new Array('http://sendearnings.com','http://bucks247.com','http://www.aanbieding.nl','http://coolhandpoker.com','http://www.deftones.com','http://www.ciao.co.uk','https://hostgator.com','https://www.facebook.com/hopenhagen','http://www.thelongevitynowconference.com','http://www.metzonderjas.nl','http://www.oxfam.org.uk/oxjam','https://www.bricksandtoys.nl','https://www.hostgator.com','https://www.zazzle.com/?rf=238005296547767598');
var alt1 = new Array('Featured Weekly Banner','Featured Weekly Banner','Featured Weekly Banner');
var currentAd1 = 0;
var imgCt1 = 14;
function cycle1() {
if (currentAd1 == imgCt1) {
currentAd1 = 0;
}
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
currentAd1++;
}
window.setInterval('cycle1()',23000);
</script>
<a href='http://sendearnings.com' id='adLink1' target='_top'>
<img src='https://paidtoclick.ca/bann/ani.gif' id='adBanner1' border='0' width='234' height'60'></a></div>
您可以在网站的主页上查看正在运行的代码。它工作正常只需要它在页面重新加载https://paidtoclick.ca上重新加载不同的横幅
真的提前谢谢了。
第二个横幅代码...
<script type='text/javascript'>
var imgs2 = new Array('https://paidtoclick.ca/bann/z1.gif','https://paidtoclick.ca/bann/Survi.gif','https://paidtoclick.ca/bann/hg3.gif','https://paidtoclick.ca/bann/z2.gif','https://paidtoclick.ca/bann/hg4.gif','https://paidtoclick.ca/bann/z3.gif','https://paidtoclick.ca/bann/z4.gif','https://paidtoclick.ca/bann/zoom.gif','https://paidtoclick.ca/bann/z5.gif','https://paidtoclick.ca/bann/hg5.gif','https://paidtoclick.ca/bann/z6.gif','https://paidtoclick.ca/bann/SLS.gif','https://paidtoclick.ca/bann/z7.gif');
var lnks2 = new Array('https://www.zazzle.com/?rf=238005296547767598','http://coolhandpoker.com','https://hostgator.com','https://www.zazzle.com/?rf=238005296547767598','https://hostgator.com','https://www.zazzle.com/?rf=238005296547767598','https://www.zazzle.com/?rf=238005296547767598','http://www.aircraftinteriorsexpo.com','https://www.zazzle.com/?rf=238005296547767598','https://hostgator.com','https://www.zazzle.com/?rf=238005296547767598','http://www.silvalifesystem.com','https://www.zazzle.com/?rf=238005296547767598');
var alt2 = new Array('Featured Weekly Banner','Featured Weekly Banner','Featured Weekly Banner');
var currentAd2 = 0;
var imgCt2 = 13;
function cycle2() {
if (currentAd2 == imgCt2) {
currentAd2 = 0;
}
var banner2 = document.getElementById('adBanner2');
var link2 = document.getElementById('adLink2');
banner2.src=imgs2[currentAd2]
banner2.alt=alt2[currentAd2]
document.getElementById('adLink2').href=lnks2[currentAd2]
currentAd2++;
}
window.setInterval('cycle2()',19000);
</script>
<a href='https://www.zazzle.com/?rf=238005296547767598' id='adLink2' target='_top'>
<img src='https://paidtoclick.ca/bann/z1.gif' id='adBanner2' border='0' width='234' height'60'></a></div>
这是网站上的完整代码。
<script type='text/javascript'>
window.onload = function(){
var imgs1 = new Array('https://paidtoclick.ca/bann/ani.gif','https://paidtoclick.ca/bann/247bux.gif','https://paidtoclick.ca/bann/brab.gif ','https://paidtoclick.ca/bann/CHP.gif','https://paidtoclick.ca/bann/Deft.gif','https://paidtoclick.ca/bann/heard.gif','https://paidtoclick.ca/bann/hg1.gif','https://paidtoclick.ca/bann/Hope.gif','https://paidtoclick.ca/bann/lon.jpg','https://paidtoclick.ca/bann/MZJ.gif','https://paidtoclick.ca/bann/oxj.gif','https://paidtoclick.ca/bann/play.jpg','https://paidtoclick.ca/bann/hg2.gif','https://paidtoclick.ca/bann/z8.gif');
var lnks1 = new Array('http://sendearnings.com','http://bucks247.com','http://www.aanbieding.nl','http://coolhandpoker.com','http://www.deftones.com','http://www.ciao.co.uk','https://hostgator.com','https://www.facebook.com/hopenhagen','http://www.thelongevitynowconference.com','http://www.metzonderjas.nl','http://www.oxfam.org.uk/oxjam','https://www.bricksandtoys.nl','https://www.hostgator.com','https://www.zazzle.com/?rf=238005296547767598');
var alt1 = new Array('Featured Weekly Banner','Featured Weekly Banner','Featured Weekly Banner');
var imgCt1 = 14;
var currentAd1 = Math.floor(Math.random() * imgCt1);
console.log(currentAd1);
function cycle1() {
currentAd1 = (currentAd1 + 1) % imgCt1;
console.log(currentAd1);
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
banner1.src=imgs1[currentAd1]
banner1.alt=alt1[currentAd1]
document.getElementById('adLink1').href=lnks1[currentAd1]
}
cycle1();
window.setInterval(cycle1,23000);
}
</script>
<a href='' id='adLink1' target='_top'>
<img src='' id='adBanner1' border='0' width='234' height'60'></a></div>
<div style='margin-left:-3px; margin-top:-4px;'><script type='text/javascript'>
window.onload = function(){
var imgs2 = new Array('https://paidtoclick.ca/bann/z1.gif','https://paidtoclick.ca/bann/Survi.gif','https://paidtoclick.ca/bann/hg3.gif','https://paidtoclick.ca/bann/z2.gif','https://paidtoclick.ca/bann/hg4.gif','https://paidtoclick.ca/bann/z3.gif','https://paidtoclick.ca/bann/z4.gif','https://paidtoclick.ca/bann/zoom.gif','https://paidtoclick.ca/bann/z5.gif','https://paidtoclick.ca/bann/hg5.gif','https://paidtoclick.ca/bann/z6.gif','https://paidtoclick.ca/bann/SLS.gif','https://paidtoclick.ca/bann/z7.gif');
var lnks2 = new Array('https://www.zazzle.com/?rf=238005296547767598','http://coolhandpoker.com','https://hostgator.com','https://www.zazzle.com/?rf=238005296547767598','https://hostgator.com','https://www.zazzle.com/?rf=238005296547767598','https://www.zazzle.com/?rf=238005296547767598','http://www.aircraftinteriorsexpo.com','https://www.zazzle.com/?rf=238005296547767598','https://hostgator.com','https://www.zazzle.com/?rf=238005296547767598','http://www.silvalifesystem.com','https://www.zazzle.com/?rf=238005296547767598');
var alt2 = new Array('Featured Weekly Banner','Featured Weekly Banner','Featured Weekly Banner');
var imgCt2 = 13;
var currentAd2 = Math.floor(Math.random() * imgCt2);
console.log(currentAd2);
function cycle2() {
currentAd2 = (currentAd2 + 1) % imgCt2;
console.log(currentAd2);
var banner2 = document.getElementById('adBanner2');
var link2 = document.getElementById('adLink2');
banner2.src=imgs2[currentAd2]
banner2.alt=alt2[currentAd2]
document.getElementById('adLink2').href=lnks2[currentAd2]
}
cycle2();
window.setInterval(cycle2,23000);
}
</script>
<a href='' id='adLink2' target='_top'>
<img src='' id='adBanner2' border='0' width='234' height'60'></a></div>