Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda