2021-01-11 20:13:12 +01:00
|
|
|
let z:HTMLCollectionOf<HTMLElement> = <HTMLCollectionOf<HTMLElement>> document.getElementsByTagName("*");
|
|
|
|
|
|
|
|
for (let i:number = 0; i < z.length; i++) {
|
|
|
|
let element:HTMLElement = z[i];
|
|
|
|
let externalFileURL:string = <string> element.getAttribute("includeHTML");
|
2021-01-12 09:48:32 +01:00
|
|
|
if (externalFileURL) {
|
2021-01-11 20:13:12 +01:00
|
|
|
let xhr:XMLHttpRequest = new XMLHttpRequest();
|
2021-01-11 20:10:32 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|