Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
My HTML snippetes content not show in the display

Can someone explain to me about the HTML snippets? See the image below (w3schools HTML snippets tutorial). Then I create a "content.html" file according to w3schools instructions. Then I create another .html file and then use the same code but don't show any content to the display. Can someone explain me how to use it?

enter image description here

When I try to my computer -

enter image description here

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is actually an error that occurred when loading your page that should that you can find in your console log similar to

html.html:1

Access to XMLHttpRequest at 'file:///content.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted.

This occurs as a result of the file being loaded using the file protocol rather than the HTTP protocol, due to the absence of a web server. As browsers do not allow you to load local files using the File protocol using an HTTP request. Which is what the code below is trying to do.

xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4) {
        if (this.status == 200) {elmnt.innerHTML = this.responseText;}
        if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
        /*remove the attribute, and call this function once more:*/
        elmnt.removeAttribute("w3-include-html");
        includeHTML();
    }
} 

To get this to work on your local system you would have to set up a web server. And access the HTML file using localhost. Depending on your intentions for implementing this you could look for a web server that will be suitable. However, I would advise Apache Server, using XAMPP which is relatively easy to install.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda