É um script que muda o link do iframe pelas abas, sem carregar a página, só muda o iframe. O Funcionamento dele pode ser visto aqui: www.soldat.com.br
Segue o código:
function changetab(tabid) { //1=noticias, 2=agenda, 3=oracoes var targetpage = ""; switch(tabid) { case 1: //document.getElementById('tabbox').src = "tabbox_noticias.php"; targetpage = 'tabbox_noticias.php'; break; case 2: //document.getElementById('tabbox').src = "tabbox_agenda.php"; targetpage = 'tabbox_agenda.php'; break; case 3: //document.getElementById('tabbox').src = "tabbox_oracoes.php"; targetpage = 'tabbox_oracoes.php'; break; } obj = findObj("tabbox"); var ua = navigator.userAgent; if (ua.indexOf('MSIE') == -1) { obj.src = targetpage; } else { obj.location.href = targetpage; } //muda estilos das tabs var i; for (i=1; i<4; i++) { obj = findObj("tab_"+i); if (tabid == i) { //document.getElementById("tab_"+i).className = "active"; obj.className = 'active'; } else { //document.getElementById("tab_"+i).className = ""; obj.className = ''; } } } // Example: obj = findObj("image1"); function findObj(theObj, theDoc) { var p, i, foundObj; if(!theDoc) theDoc = document; if( (p = theObj.indexOf("?")) > 0 && parent.frames.length) { theDoc = parent.frames[theObj.substring(p+1)].document; theObj = theObj.substring(0,p); } if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj]; for (i=0; !foundObj && i < theDoc.forms.length; i++) foundObj = theDoc.forms[i][theObj]; for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) foundObj = findObj(theObj,theDoc.layers[i].document); if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj); return foundObj; }
Acho que o erro está aqui:
Mas não sei como resolve o problema... Será que por JQuery fica melhor?var ua = navigator.userAgent;
if (ua.indexOf('MSIE') == -1) {
obj.src = targetpage;
} else {
obj.location.href = targetpage;
}
Obrigado.
Edição feita por: Wilk, 16/11/2008, 09:14.