17 lines
643 B
JavaScript
17 lines
643 B
JavaScript
let z = document.getElementsByTagName("*");
|
|
for (let i = 0; i < z.length; i++) {
|
|
let element = z[i];
|
|
let externalFileURL = element.getAttribute("includeHTML");
|
|
if (externalFileURL) {
|
|
let xhr = new XMLHttpRequest();
|
|
xhr.onreadystatechange = function() {
|
|
if (this.readyState == 4) {
|
|
if (this.status == 200) { element.innerHTML = this.responseText; }
|
|
if (this.status == 404) { element.innerHTML = "Page not found."; }
|
|
element.removeAttribute("includeHTML");
|
|
}
|
|
}
|
|
xhr.open("GET", externalFileURL, true);
|
|
xhr.send();
|
|
}
|
|
}
|