Looking for a script that can dynamically change the src attribute of iframes at different intervals. The time between each change varies depending on the specific iframe.
For example: Page Loads Google.com is loaded. 15 seconds later Yahoo.com is loaded. 37 seconds later Ask.com is loaded. 12 seconds later Dogpile.com is loaded. and so on...
This is what I've attempted:
<html>
<head>
<meta charset="utf-8" />
<title>Monitor Presidency</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.11.8/semantic.min.js"></script>
</head>
<body>
<div style="width: 100%; display: flex;">
<div class="ui teal progress" data-percent="0" id="example1" style="width: 90%;margin-bottom: 0px">
<div class="bar"></div>
</div>
<div class="ui icon buttons" style="width: 10%">
<button class="ui button" style="width: 25%" onclick="subtract_one()">
<i class="left chevron icon"></i>
</button>
<button class="ui button " style="width: 25%" onclick="start()">
<i class="play icon"></i>
</button>
<button class="ui button" style="width: 25%" onclick="pause_application()">
<i class="pause icon"></i>
</button>
<button class="ui button" style="width: 25%" onclick="add_one()">
<i class="right chevron icon"></i>
</button>
</div>
</div>
<iframe id="container" class="frame_monitor" style="width: 100%;height: 100%;" src="www.google.com"></iframe>
<iframe id="shipping_hl" class="frame_monitor" style="width: 100%;height: 100%;display: none;" src="www.yahoo.com"></iframe>
<iframe id="shipping_hl_accumulated" class="frame_monitor" style="width: 100%;height: 100%;display: none;" src="www.terra.com"></iframe>
</body>
<script>
var monitor_array = ["container", "shipping_hl", "shipping_hl_accumulated"];
var current_monitor = 0;
var progress = 0;
var myVar;
var setIntervalUpdateFrame;
function add_one() {
/* if (current_monitor === 2) {
current_monitor = 0;
} else {
current_monitor++;
}
$('.frame_monitor').css('display', 'none');
document.getElementById(monitor_array[current_monitor]).style.display = "";*/
progress = 100;
stopFunction();
start();
/* if (current_monitor === 2) {
current_monitor = 0;
} else {
current_monitor++;
}*/
};
function subtract_one() {
//progresso = 100;
if (current_monitor === 0) {
current_monitor = 2;
} else {
current_monitor--;
}
$('.frame_monitor').css('display', 'none');
document.getElementById(monitor_array[current_monitor]).style.display = "";
progress = 0;
stopFunction();
start();
};
function start() {
clearInterval(setIntervalUpdateFrame);
stopFunction();
myVar = setInterval(function () {
if (progress === 100) {
progress = 0;
if (current_monitor === 2) {
location.reload();
//num_monitor = 0;
} else {
current_monitor++;
}
$('.frame_monitor').css('display', 'none')
document.getElementById(monitor_array[current_monitor]).style.display = "";
};
progress++;
progress++;
$('#example1').data('percent', progress);
$('#example1').progress();
}, 3800);
}
function stopFunction() {
clearInterval(myVar);
//atualiza_frame();
}
start();
function pause_application(){
clearInterval(myVar);
update_frame();
}
function update_frame() {
clearInterval(setIntervalUpdateFrame);
setIntervalUpdateFrame = setInterval(function () {
document.getElementById(monitor_array[current_monitor]).src=document.getElementById(monitor_array[current_monitor]).src;
},1);
}
</script>
</html>