samedi 1 avril 2017

How to randomly reload iframe pages

What i currently have:

I have the below website with the following javascript with a few iframes. At present the below javascript code will set a random time and reload the whole page. This works perfectly fine.

<script>
function reloadMe() {
    window.location.reload();
}
function getInterval(){
    var lowerBound = 60;  // 60 seconds
    var upperBound = 480; // 8  minutes

    var randNum = Math.floor((upperBound-lowerBound+1)*Math.random()+lowerBound) * 1000;
    return randNum;
}
var interval = getInterval();
var srcInterval = setInterval("reloadMe()",interval);
</script>


<iframe id="page1" src="http://ift.tt/2oucSzY"></iframe>
<iframe id="page2" src="http://ift.tt/2on6bT5"></iframe>
<iframe id="page3" src="http://ift.tt/2ounXRx"></iframe>
<iframe id="page4" src="http://ift.tt/2on6QUC"></iframe>
<iframe id="page5" src="http://ift.tt/2ougEsW"></iframe>
<iframe id="page6" src="http://ift.tt/2omZz7a"></iframe>
<iframe id="page7" src="http://ift.tt/2ouhztH"></iframe>
<iframe id="page8" src="http://ift.tt/2omSaow"></iframe>

What i am trying to do:

What i want to do is have one script which applies to all the iframes on the page, so each iframe will randomly reload, then after that iframe is randomly reloaded it runs through this script to set a new random reload time on the page.

Is this actually possible ?




Aucun commentaire:

Enregistrer un commentaire