From acf54ae5e7e91d7c4ef58f16e8403d62b9135b45 Mon Sep 17 00:00:00 2001 From: PJ568 Date: Sat, 10 Jun 2023 21:15:56 +0800 Subject: [PATCH] Add files via upload --- js/include.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 js/include.js diff --git a/js/include.js b/js/include.js new file mode 100644 index 00000000..648b7dff --- /dev/null +++ b/js/include.js @@ -0,0 +1,19 @@ +function includeHTML() { + var elements = document.getElementsByTagName("include"); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var file = element.getAttribute("src"); + if (file) { + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState === 4 && this.status === 200) { + element.innerHTML = this.responseText; + } + }; + xhttp.open("GET", file, true); + xhttp.send(); + } + } + } + + document.addEventListener("DOMContentLoaded", includeHTML); \ No newline at end of file