AJAX e IE7
Salve salve galera iMasters,
Veja bem, estou com um problemaço e conto com a ajuda de vcs.
Sou novo no AJAX e como os layouts de sites com imagens (PHOTOSHOP) estão em alta eu procurei o ajax para carregar meu conteúdo html (páginas) em uma DIV... Garimpei um script, do qual eu entendi legal, mas dei problema ao carregar no IE7. Pô no Firefox carregou legal.
Ai segue o codigo será que vcs poderiam me dar uma força, me dizendo o que esta errado?
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>site exemplo</title><!-- Aqui eu chamo a ação javascript com ajax-->
<script src="actions.js" type="text/javascript"></script>
</head>
<body onload="ajaxHTML('conteudo','paginicial.html');">
<a href="#" onclick="ajaxHTML('conteudo','pag2.html');">Link para pagina dois</a>
<div id="conteudo"> <!--Aqui entra a pagina html logo no inicio do carregamento--></div>
</body>
</html>pag2.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>site exemplo</title>
</head>
<body>
<p>pagina 2 do meu site</p>
<p>com imagesns .jpg etc... </p>
</body>
</html>paginicial.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="[http://www.w3.org/1999/xhtml">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>site exemplo</title>
</head>
<body>
<p>pagina inicial do site</p>
<p>com imagesns .jpg etc... </p>
</body>
</html>actions.js
// JavaScript Document
function ajaxHTML(id,url){
//Obtém o objeto HTML
objetoHTML=document.getElementById(id);
//Exibe "Carregando..."
objetoHTML.innerHTML="Carregando...";
try{
xmlhttp = new XMLHttpRequest();
}catch(ee){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch(E){
xmlhttp = false;
}
}
}
xmlhttp.open("GET",url);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4){
retorno=unescape(xmlhttp.responseText.replace(/\+/g," "));
objetoHTML.innerHTML=retorno;
}
}
xmlhttp.send(null);
};
mostrarRelogio=function(){
horaAtual = new Date()hora = horaAtual.getHours()
minuto = horaAtual.getMinutes()
segundo = horaAtual.getSeconds()
horaImprimivel = hora + " : " + minuto + " : " + segundo
document.getElementById('relogio').value=""+ horaImprimivel;
setTimeout("mostrarRelogio()",1000);
};
Então... funciona perfeitinho no Firefox mas no IE7 ... não dá certo . <_<
Se vcs me derem um help eu fico muito grato!!!
Valeu galera!!!
[]'s
Discussão (2)
Carregando comentários...