Skip to content

Commit a1ff1eb

Browse files
author
VentGrey
committed
Alv reescribir la función del navbar xd
1 parent b657461 commit a1ff1eb

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

navbar.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
function includeHTML() {
2-
const z = document.getElementsByTagName("*");
3-
for (let i = 0; i < z.length; i++) {
4-
const elmnt = z[i];
5-
const file = elmnt.getAttribute("inc");
6-
if (file) {
7-
const xhttp = new XMLHttpRequest();
8-
xhttp.onreadystatechange = function() {
9-
if (this.readyState == 4) {
10-
if (this.status == 200) { elmnt.innerHTML = this.responseText; }
11-
elmnt.removeAttribute("inc");
12-
}}
13-
xhttp.open("GET", file, true);
14-
xhttp.send();
15-
return;
1+
async function includeHTML() {
2+
const z = document.querySelectorAll('[inc]');
3+
for (const elmnt of z) {
4+
const file = elmnt.getAttribute('inc');
5+
try {
6+
const response = await fetch(file);
7+
if (response.ok) {
8+
elmnt.innerHTML = await response.text();
9+
elmnt.removeAttribute('inc');
1610
}
11+
} catch (error) {
12+
console.error(error);
1713
}
18-
};
14+
}
15+
}

0 commit comments

Comments
 (0)