Capture the elements through the ID, and create an action on the button, checking which next index is to be clicked, each click, adds a position, if it is equal to the url total, it resets to index 0 ( beginning):
<button id="next">Proximo</button>
<iframe id="rotator" src="http://www.1.com.br"width='100%'height='100%'></iframe><script>window.onload=function(){/*ParacapturaroelementoporgetElementById,independentedaposiçãodoscript,énecessárioqueodocumentowindowtenhasidolido*/varurls=['http://www.1.com.br','http://www.2.com.br','http://www.3.com.br'];varindex=1;varclick_button=document.getElementById('next');varel=document.getElementById('rotator');click_button.onclick=function(){if(index===urls.length){index=0;}el.src=urls[index];index+=1;}};</script>
IfyouwanttoimplementusingPHPdirectlyinjavascript,youcandothat,butIdonotrecommendit,prefertosendthedataviaPOSTorGET,butthatwouldbeforanotherquestion:
<?php$urls=array('http://www.1.com.br','http://www.2.com.br','http://www.3.com.br');?><script>window.onload=function(){/*ParacapturaroelementoporgetElementById,independentedaposiçãodoscript,énecessárioqueodocumentowindowtenhasidolido*/varurls=<?phpecho'["'.implode('","', $urls).'"];'; ?>
var index = 1;
var click_button = document.getElementById('next');
var el = document.getElementById('rotator');
click_button.onclick = function() {
if ( index === urls.length ) {
index = 0;
}
el.src = urls[index];
index += 1;
}
};
</script>
Resolution for new cases:
Case 1:
<script>
window.onload = function() {
/* Para capturar o elemento por
getElementById, independente da posição do script,
é necessário que o documento window tenha sido lido */
var urls = [
'http://www.1.com.br',
'http://www.2.com.br',
'http://www.3.com.br'
];
var index = 1;
var click_button = document.getElementById('next');
var el = document.getElementById('rotator');
click_button.onclick = function() {
if ( index === urls.length -1 ) {
this.disabled = true;
}
el.src = urls[index];
index += 1;
}
};
</script>
Case 2:
It was not exactly clear what the problem was. Because it loads each iframe on the same page, if it's updating, it's not about the code I've posted, but the rest of the code that exists in your application, I think.