Jump to content


Wilk

Member Since 11/07/2005
Offline Last Active 17/11/2008, 18:00
-----

#946597 Menu Com Abas Que Muda O Iframe / Jquery!

Posted by Wilk on 15/11/2008, 16:20

Fala pessoal, estou com um problema aqui... o script não funciona no Opera, nem no Chrome.

É 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:

var ua = navigator.userAgent;
if (ua.indexOf('MSIE') == -1) {
obj.src = targetpage;
} else {
obj.location.href = targetpage;
}

Mas não sei como resolve o problema... Será que por JQuery fica melhor?

Obrigado.


IPB Skin By Virteq