Jump to content
Fórum Script Brasil
  • 0

Incluir conteúdo html em div, problemas como o Chrome



Olá, uso um script ajax para incluir o conteúdo de um arquivo html em uma div.

Funciona normalmente no IE e Fire Fox, mas não teve jeito de funcionar no Chrome.

arquivo ajax.js

function GetXMLHttp() {
var xmlhttp=false;
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
try //Google Chrome
var xmlhttp = new window.XMLHttpRequest();
xmlDoc = xmlhttp.responseXML.documentElement;
xmlhttp = false;
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
return xmlhttp;

var xmlRequest = GetXMLHttp();

function mostra_conetudo(valor){
var url = valor;

xmlRequest.onreadystatechange = mudancaEstado;

if (xmlRequest.readyState == 1) {
document.getElementById("inclui_conteudo").innerHTML = "carregando...";

return url;

function mudancaEstado(){
if (xmlRequest.readyState == 4){
document.getElementById("inclui_conteudo").innerHTML = xmlRequest.responseText;
Pagina index.html
    &lt;script language="javascript" src="ajax.js"></script>

<a href="#" onclick="mostra_conetudo('conteudo.html')" class="lmenu">Que somos</a>

<div id="inclui_conteudo" class="conetudo"></div>

Página de conteúdo a ser incluído conteudo.html
Apenas um teste

Alguém sabe como resolver?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    • Total Topics
    • Total Posts
  • Create New...