Jump to content


Photo

Menu Com Abas Que Muda O Iframe / Jquery!


  • Faça o login para participar
8 replies to this topic

#1 Wilk

Wilk

    Turista

  • Usuários
  • 40 posts
  • Sexo:Masculino

Posted 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.

Edição feita por: Wilk, 16/11/2008, 09:14.

Procurando um jogo online simples e leve? Conheça SoldaT

;)

#2 Alex Hiroshi

Alex Hiroshi

    Super Veterano

  • Ex-Admins
  • 4923 posts
  • Sexo:Masculino
  • Localidade:São Paulo - SP

Posted 15/11/2008, 22:30

Você diz para o script que se for o IE, para usar a linha obj.src = targetpage; e se for outros, usar obj.location.href = targetpage. O Opera e o Chrome também caem nesse 'outros', mas o certo seria na linha do IE - pelo menos para o Opera.

Troca a linha do if por:
if ( (ua.indexOf('MSIE') == -1) || (ua.indexOf('Opera') != -1) || (ua.indexOf('Chrome') != -1) )
Eu não sei se o Chrome é assim, mas testa aí.
Fórum WMO - Equipe de Desenvolvimento / Banco de Dados - Ex-Administrador

#3 Wilk

Wilk

    Turista

  • Usuários
  • 40 posts
  • Sexo:Masculino

Posted 17/11/2008, 11:46

Então, mas aí caimos em outro problema xD Versões antigas do opera (do ano passado) caem no segundo caso. Então provavelmente eu vou Oconseguir arrumar o script pra funcionar nas versoes mais recentes de todos os navegadores (o que é bom)... mas em compensação quem estiver usando a versão 5.0 do Opera vai ter problemas.

Gostaria de saber se com o JQuery, o problema poderia ser resolvido, sabes mexer? Estava lendo um tutorial e parece ser bem fácil puxar um elemento com JQuery... daí não sei se pelo JQuery 1 comando só bastasse... tipo $(#tabbox).COMANDODEREDIRECIONAMENTO.seilauq... Dái também não sei se com o JQuery eu poderia dispensar essa função de FindObj, alguém pode ajuda?


(Não sei nadad e JavaScritp, nem JQuery... td intuição mesmo, xD)

Obrigado...

Bom, como falei nunca programei javascript, nem jQuery... mas diante desse problema resolvi ir atrás do jQuery e, além de solucionar o problema, eu consegui substituir todo esse código em java por simples comandos em jQuery... Fica o código pra quem precisar algum dia...


<script type="text/javascript" src="admin/jquery-1.2.6.js"></script>
<script type="text/javascript">
$(function() {

$("#tabnav a").each(function() {
var redir = $(this).attr("title");

$(this).click(function() {
$("#tabnav a").removeClass();
$("#tabbox").attr({
src: redir
});
$(this).addClass("active");
});

});

});

Vlw \o
Procurando um jogo online simples e leve? Conheça SoldaT

;)

#4 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 25/09/2017, 09:55

Pills Populaires En Ligne Acheter Priligy Usa generic cialis Propecia Peligroso buy brand name accutane

#5 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 01/10/2017, 05:26

Viagra No Prescription Prix De Cytotec Viagra Wurzel cialis Viagra Kauf De

#6 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 03/10/2017, 13:01

Ou Trouver Du Viagra En France Ed Pills Online Propecia De 1 Miligramo viagra online pharmacy Levitra Generico Online

#7 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 10/10/2017, 22:50

Priligy Au Bottes online pharmacy Que Es Kamagra Hydrochlorothiazide Us With Free Shipping By Money Order Buy Cialis Online Nopw
Priligy Ricetta Medica viagra Amoxicillin Trihydrate For Dogs
Zithromax How To Take Fedex Shipping Stendra No Physician Approval Levitra Stopped Working bayer generic generic levitra 100mg Amoxicillin Induce Cyp2d6 Generic Priligy Dapoxetine 60mg
Amoxicillin Side Effects Sexual Excitement viagra Baclofene 60 Mg

#8 LarPhozyHah

LarPhozyHah

    Super Veterano

  • Usuários
  • 14515 posts
  • Sexo:Masculino
  • Localidade:San Miguel de Tucuman

Posted 27/10/2017, 16:22

Powerpill Fluoxetine 20mg cheap cialis Cephalexin Bromhexina Viagra Sin Receta Valencia
Kamagra Aus Uk Viagra Bei Frau Usa Viagra Online Pharmacy viagra Amoxicilline 500 Dose
Sildenafil 25 Mg Propecia On Sale Pharmacy Cephalexin Discovery viagra Provental Inhaler Without A Script
Kamagra Prix En Pharmacie Baclofen En Ligne 25mg viagra Zithromax Without Prescription Acheter Kamagra Suisse

#9 Miguceamma

Miguceamma

    MiguPenjisse

  • Usuários
  • 13201 posts

Posted 27/10/2017, 16:41

Buy Generic Effexor Online viagra Achat Cialis Petite Quantite Rico Rio Pharmacy




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq