Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

pensar

Galeria em ajax nao funfa no IE

Recommended Posts

Galera baixei um script de galeria feita em ajax e ele funciona da seguinte maneira..

 

Antes de cadastrar a galeria você tem que fazer o upload da pasta com as fotos para o servidor.

 

Ate ai beleza

 

No formularo de cadastro de galeria você tem os campos data, evento, diretorio e foto principal

 

Quando você coloca o direotorio que ja esta no servidor ele avisa se esta ok ou nao

 

e no campo foto principal se estiver ok você clica no link lista e ele lista as fotos do diretorio para você escolher qual você quer na principal..

 

no firefox esta tudo 100 % mas no IE quando clico em listar ele nao mostra nada ...

 

Ele é chamado por uma funcao em javascript...

 

o que pode ser???

 

Vou postar o ajax.js

 

try{	xmlhttp = new XMLHttpRequest();}catch(ee){	try{		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");	}catch(e){		try{			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");		}catch(E){			xmlhttp = false;		}	}}foto = 0;inicioSlide = 0;campo = "idevento";tipo = "DESC";pg = 0;var ajax = {		album : function(pasta, pagina){				pg = pagina;		diretorio = pasta;		alvo = document.getElementById('miniaturas');		anime.fade(alvo, 100, 20);		xmlhttp.open('GET', 'include/ajax.php?pasta='+pasta+'&pg='+pagina, true);		xmlhttp.onreadystatechange = function(){			if(xmlhttp.readyState == 4) {				if(xmlhttp.status == 200) {					alvo.innerHTML = xmlhttp.responseText;					imagens = alvo.getElementsByTagName('img');					ajax.exibe(imagens[0].title, imagens[0]);					ultimo = imagens.length;					imagens[ultimo-1].onload = anime.appear(alvo, 20, 100, 100);				}				}		}		xmlhttp.send(null);	},		mostraFoto : function(lado){				total_de_fotos = document.getElementById('TotalDeFotos').value;				if(lado == 'ant') {			if(foto > 0) {				foto -= 1;				ajax.exibe(imagens[foto].title, imagens[foto]);			}else{								pg -= 1;						if(pg >= 0) {					ajax.album(diretorio, pg);									}			}		}else{			if(foto < 14) {				foto = parseInt(foto)+1;				if(imagens[foto]){					ajax.exibe(imagens[foto].title, imagens[foto]);				}else{					foto -= 1;				}			}else{				pg += 1;						if(pg < (total_de_fotos/15)) {					ajax.album(diretorio, pg);									}			}		}	},		exibe : function(caminho, proxima){		foto = proxima.id				exibe = document.getElementById('foto');		loaded = document.getElementById('load');		anime.fade(loaded, 100, 20, 100);		loaded.style.display = 'block';		exibe.style.display = 'none';		exibe["src"] = caminho;		exibe.onload = function(){			loaded.style.display = 'none';			exibe.style.display = 'block';			anime.appear(exibe, 0, 100, 100); 		}					},		abreEmail : function() {				div = document.getElementById('tudo');		if(!document.getElementById('mail')){						mail = document.createElement('div');			mail['id'] = 'mail';			div.appendChild(mail);					anime.appear(mail, 0, 100, 500);			anime.resizeAbre(mail, 35, 35, 350, 18, 18, 180);					}else{			alert('A tela de e-mail já se encontra aberta!');		}			},		fechaEmail : function() {				mail.innerHTML = '';			anime.fade(mail, 100, 0, 500);				anime.resizeFecha(mail, 350, 35, 35, 180, 18, 18);			},		enviaEmail : function(){				img = document.getElementById('foto').src;		nome = document.getElementById('nome').value		destino = document.getElementById('destino').value		email = document.getElementById('email').value				if(nome == "" || nome == null){			alert("Por favor preencha seu nome!");			return false;		} else if(destino == "" || destino == null){			alert("Por favor preencha seu nome do destinatario!");			return false;		}else if(email == "" || email == null){			alert("Por favor preencha o e-mail pra quem a foto sera enviada!");			return false;		}else{						param = "nome="+nome+"&destino="+destino+"&email="+email+"&img="+img;			xmlhttp.open("POST", "include/email.php", true);			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			xmlhttp.onreadystatechange = function(){				if(xmlhttp.readyState == 1) {					document.getElementById('formulario').innerHTML = carregandoHTML;				}				if(xmlhttp.readyState == 4) {					if(xmlhttp.status == 200){						document.getElementById('enviandomail').innerHTML = '<span>'+xmlhttp.responseText+'</span>';					}				}			}			xmlhttp.send(param);					}			},		camposForm : function(oForm){		var aParams = new Array();		for (var i=0; i < oForm.length; i++) {			var sParam = oForm[i].id;			sParam += "=";			sParam += oForm[i].value;			aParams.push(sParam);		}		return aParams.join("&");	},		cadastraGaleria : function(){				formulario = document.cadastra.elements;		param = ajax.camposForm(formulario);				xmlhttp.open('POST', '../include/ajax.php?cadastro=1', true);		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');		xmlhttp.onreadystatechange = ajax.repostasCadastro;		xmlhttp.send(param);			},		repostasCadastro : function(){				mensagens = document.getElementById('msg');				if(xmlhttp.readyState == 1)							mensagens.innerHTML = 'Aguarde...';				if(xmlhttp.readyState == 4) {			if(xmlhttp.status == 200) {				mensagens.innerHTML = xmlhttp.responseText;				ajax.listaGaleria(campo, tipo);				document.cadastra.reset();			}		}			},		listaGaleria : function(campo, tipo){				ordena = campo;		ordenar = tipo;				local = document.getElementById('lista');				xmlhttp.open('GET', '../include/ajax.php?lista=1&campo='+ordena+'&tipo='+ordenar, true);		xmlhttp.onreadystatechange = function(){			if(xmlhttp.readyState == 1) {				if(document.getElementById('tabelaLista'))					anime.fade(document.getElementById('tabelaLista'), 100, 20, 500);			}			if(xmlhttp.readyState == 4) {				if(xmlhttp.status == 200){					local.innerHTML = xmlhttp.responseText;					if(document.getElementById('tabelaLista'))						anime.fade(document.getElementById('tabelaLista'), 20, 100, 500);				}			}		}		xmlhttp.send(null);			},		deletaGaleria : function(id){				if(confirm("Tem certeza que deseja excluir a galeria!")) {			xmlhttp.open('GET', '../include/ajax.php?deleta=1&id='+id, true);			xmlhttp.onreadystatechange = ajax.repostasCadastro;			xmlhttp.send(null);		}			},		edicaoTratamento : function(){				formulario = document.cadastra.elements;		if(xmlhttp.readyState == 1)			formulario[1].value = 'Aguarde...';					if(xmlhttp.readyState == 4) {			if(xmlhttp.status == 200) {				codigo = eval('('+xmlhttp.responseText+')');				for(i=0;i<formulario.length-1;i++){					formulario[i].value = codigo[i];				}				abrePasta = codigo['pasta'];			}		}			},		editaGaleria : function(id){				xmlhttp.open('GET', '../include/ajax.php?edita=1&id='+id, true);		xmlhttp.onreadystatechange = ajax.edicaoTratamento;		xmlhttp.send(null);			},		verificaDiretorio : function(pasta){				resp = document.getElementById('respotadir');				xmlhttp.open('GET', '../include/dir.php?pasta='+pasta, true);		xmlhttp.onreadystatechange = function(){			if(xmlhttp.readyState == 4){				if(xmlhttp.status == 200) {					if(xmlhttp.responseText == '1'){						resp.innerHTML = '* pasta ok!';						resp.style.color = '#99CC00';						abrePasta = pasta;					}else{						resp.innerHTML = '* pasta não encontrada!';						resp.style.color = '#FF0000';						abrePasta = false;					}				}			}		}		xmlhttp.send(null);			},		listaImagens : function(){				listaFotos = document.getElementById('listaFotos');		listaFotos.style.display = 'block';				if(abrePasta !== null) {			xmlhttp.open('GET', '../include/dir.php?imagens=1&dir='+abrePasta, true);			xmlhttp.onreadystatechange = function(){				if(xmlhttp.readyState == 1) {					listaFotos.innerHTML = "carregando...";				}				if(xmlhttp.readyState == 4){					if(xmlhttp.status == 200) {						listaFotos.innerHTML = xmlhttp.responseText;									}				}			}			xmlhttp.send(null);		}else{						alert("Pasta Invalida!");					}			},		completaCampo : function(valor){				document.getElementById('foto').value = valor;			},		fechaLista : function(){				document.getElementById('listaFotos').style.display = 'none';			}}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Segue o formulario

<form action="return false" method="post" enctype="application/x-www-form-urlencoded" name="cadastra" id="cadastra"><input id="id" name="id" type="hidden" value="" /> <table width="100%" border="0" cellspacing="0" cellpadding="0" id="cadastroTab"> <tr> <th width="30%">Data do Evento: </th> <td width="70%"> <label> <input name="data" type="text" class="campos" id="data" size="10" /> dd/mm/aaaa</label></td> </tr> <tr> <th>Evento:</th> <td><input name="evento" type="text" class="campos" id="evento" size="50" /></td> </tr> <tr> <th>Diretório:</th> <td><input name="dir" type="text" class="campos" id="dir" size="30" onblur="ajax.verificaDiretorio(this.value)" /> <span id="respotadir"></span></td> </tr> <tr> <th>Foto Principal: </th> <td><input name="foto" type="text" class="campos" id="foto" size="30" /> <span id="listafotos"><a href="java script:void(0);" onclick="ajax.listaImagens();">lista</a></span></td> </tr> <tr> <th> </th> <td><label> <input type="button" class="botao" onclick="ajax.cadastraGaleria()" value="Confirma" /> </label></td> </tr> </table></form><div id="listaFotos"></div><div id="msg"></div><div id="lista"></div>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Galera disponiblizei o script no servidor para teste para darem uma olhada

 

MAs lembrando ele funciona legal no firefox mas no IE nao ...

 

Acesse aqui

 

 

usuario demo

seha demo

 

 

 

Cliquem em editar e cliquem no link lista ao lado do campo foto principal... o problema é que no IE ele nao esta listando as imagens ...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Nao to achando tambem pois o script eu peguei do laboratorio..Mas o tm porque funciona no firefox e no iE nao ..?Nao encontrei a variavel .. ainda ...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Codigo alterada mas continua o mesmo

nao abre a lista..

 

try{

xmlhttp = new XMLHttpRequest();

}catch(ee){

try{

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

}catch(e){

try{

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

}catch(E){

xmlhttp = false;

}

}

}

 

foto = 0;

 

inicioSlide = 0;

 

campo = "idevento";

 

tipo = "DESC";

 

var abrePasta;

 

pg = 0;

 

var ajax = {

 

album : function(pasta, pagina){

 

pg = pagina;

diretorio = pasta;

alvo = document.getElementById('miniaturas');

anime.fade(alvo, 100, 20);

xmlhttp.open('GET', 'include/ajax.php?pasta='+pasta+'&pg='+pagina, true);

xmlhttp.onreadystatechange = function(){

if(xmlhttp.readyState == 4) {

if(xmlhttp.status == 200) {

alvo.innerHTML = xmlhttp.responseText;

imagens = alvo.getElementsByTagName('img');

ajax.exibe(imagens[0].title, imagens[0]);

ultimo = imagens.length;

imagens[ultimo-1].onload = anime.appear(alvo, 20, 100, 100);

}

}

}

xmlhttp.send(null);

},

 

mostraFoto : function(lado){

 

total_de_fotos = document.getElementById('TotalDeFotos').value;

 

if(lado == 'ant') {

if(foto > 0) {

foto -= 1;

ajax.exibe(imagens[foto].title, imagens[foto]);

}else{

pg -= 1;

if(pg >= 0) {

ajax.album(diretorio, pg);

}

}

}else{

if(foto < 14) {

foto = parseInt(foto)+1;

if(imagens[foto]){

ajax.exibe(imagens[foto].title, imagens[foto]);

}else{

foto -= 1;

}

}else{

pg += 1;

if(pg < (total_de_fotos/15)) {

ajax.album(diretorio, pg);

}

}

}

},

 

exibe : function(caminho, proxima){

 

foto = proxima.id

 

exibe = document.getElementById('foto');

loaded = document.getElementById('load');

anime.fade(loaded, 100, 20, 100);

loaded.style.display = 'block';

exibe.style.display = 'none';

exibe["src"] = caminho;

exibe.onload = function(){

loaded.style.display = 'none';

exibe.style.display = 'block';

anime.appear(exibe, 0, 100, 100);

}

 

 

},

 

abreEmail : function() {

 

div = document.getElementById('tudo');

if(!document.getElementById('mail')){

 

mail = document.createElement('div');

mail['id'] = 'mail';

div.appendChild(mail);

 

anime.appear(mail, 0, 100, 500);

anime.resizeAbre(mail, 35, 35, 350, 18, 18, 180);

 

}else{

alert('A tela de e-mail já se encontra aberta!');

}

 

},

 

fechaEmail : function() {

 

mail.innerHTML = '';

anime.fade(mail, 100, 0, 500);

anime.resizeFecha(mail, 350, 35, 35, 180, 18, 18);

 

},

 

enviaEmail : function(){

 

img = document.getElementById('foto').src;

nome = document.getElementById('nome').value

destino = document.getElementById('destino').value

email = document.getElementById('email').value

 

if(nome == "" || nome == null){

alert("Por favor preencha seu nome!");

return false;

} else if(destino == "" || destino == null){

alert("Por favor preencha seu nome do destinatario!");

return false;

}else if(email == "" || email == null){

alert("Por favor preencha o e-mail pra quem a foto sera enviada!");

return false;

}else{

 

param = "nome="+nome+"&destino="+destino+"&email="+email+"&img="+img;

xmlhttp.open("POST", "include/email.php", true);

xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xmlhttp.onreadystatechange = function(){

if(xmlhttp.readyState == 1) {

document.getElementById('formulario').innerHTML = carregandoHTML;

}

if(xmlhttp.readyState == 4) {

if(xmlhttp.status == 200){

document.getElementById('enviandomail').innerHTML = '<span>'+xmlhttp.responseText+'</span>';

}

}

}

xmlhttp.send(param);

 

}

 

},

 

camposForm : function(oForm){

var aParams = new Array();

for (var i=0 ; i < oForm.length; i++) {

var sParam = oForm.id;

sParam += "=";

sParam += oForm.value;

aParams.push(sParam);

}

return aParams.join("&");

},

 

cadastraGaleria : function(){

 

formulario = document.cadastra.elements;

param = ajax.camposForm(formulario);

 

xmlhttp.open('POST', '../include/ajax.php?cadastro=1', true);

xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');

xmlhttp.onreadystatechange = ajax.repostasCadastro;

xmlhttp.send(param);

 

},

 

repostasCadastro : function(){

 

mensagens = document.getElementById('msg');

 

if(xmlhttp.readyState == 1)

mensagens.innerHTML = 'Aguarde...';

 

if(xmlhttp.readyState == 4) {

if(xmlhttp.status == 200) {

mensagens.innerHTML = xmlhttp.responseText;

ajax.listaGaleria(campo, tipo);

document.cadastra.reset();

}

}

 

},

 

listaGaleria : function(campo, tipo){

 

ordena = campo;

ordenar = tipo;

 

local = document.getElementById('lista');

 

xmlhttp.open('GET', '../include/ajax.php?lista=1&campo='+ordena+'&tipo='+ordenar, true);

xmlhttp.onreadystatechange = function(){

if(xmlhttp.readyState == 1) {

if(document.getElementById('tabelaLista'))

anime.fade(document.getElementById('tabelaLista'), 100, 20, 500);

}

if(xmlhttp.readyState == 4) {

if(xmlhttp.status == 200){

local.innerHTML = xmlhttp.responseText;

if(document.getElementById('tabelaLista'))

anime.fade(document.getElementById('tabelaLista'), 20, 100, 500);

}

}

}

xmlhttp.send(null);

 

},

 

deletaGaleria : function(id){

 

if(confirm("Tem certeza que deseja excluir a galeria!")) {

xmlhttp.open('GET', '../include/ajax.php?deleta=1&id='+id, true);

xmlhttp.onreadystatechange = ajax.repostasCadastro;

xmlhttp.send(null);

}

 

},

 

edicaoTratamento : function(){

 

formulario = document.cadastra.elements;

if(xmlhttp.readyState == 1)

formulario[1].value = 'Aguarde...';

 

if(xmlhttp.readyState == 4) {

if(xmlhttp.status == 200) {

codigo = eval('('+xmlhttp.responseText+')');

for(i=0;i<formulario.length-1;i++){

formulario.value = codigo;

}

abrePasta = codigo['pasta'];

}

}

 

},

 

editaGaleria : function(id){

 

xmlhttp.open('GET', '../include/ajax.php?edita=1&id='+id, true);

xmlhttp.onreadystatechange = ajax.edicaoTratamento;

xmlhttp.send(null);

 

},

 

verificaDiretorio : function(pasta){

 

resp = document.getElementById('respotadir');

 

xmlhttp.open('GET', '../include/dir.php?pasta='+pasta, true);

xmlhttp.onreadystatechange = function(){

if(xmlhttp.readyState == 4){

if(xmlhttp.status == 200) {

if(xmlhttp.responseText == '1'){

resp.innerHTML = '* pasta ok!';

resp.style.color = '#99CC00';

abrePasta = pasta;

}else{

resp.innerHTML = '* pasta não encontrada!';

resp.style.color = '#FF0000';

abrePasta = false;

}

}

}

}

xmlhttp.send(null);

 

},

 

listaImagens : function(){

 

listaFotos = document.getElementById('listaFotos');

listaFotos.style.display = 'block';

 

if(abrePasta !== null) {

xmlhttp.open('GET', '../include/dir.php?imagens=1&dir='+abrePasta, true);

xmlhttp.onreadystatechange = function(){

if(xmlhttp.readyState == 1) {

listaFotos.innerHTML = "carregando...";

}

if(xmlhttp.readyState == 4){

if(xmlhttp.status == 200) {

listaFotos.innerHTML = xmlhttp.responseText;

}

}

}

xmlhttp.send(null);

}else{

 

alert("Pasta Invalida!");

 

}

 

},

 

completaCampo : function(valor){

 

document.getElementById('foto').value = valor;

 

},

 

fechaLista : function(){

 

document.getElementById('listaFotos').style.display = 'none';

 

}

}

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.