Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!