-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (25 loc) · 1 KB
/
Copy pathscript.js
File metadata and controls
26 lines (25 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
async function loadPage(basepath,page){
const container = document.getElementById('pageToLoad');
const baseContainer = document.getElementById('basePagerContainer');
baseContainer.href = "";
if (container) {
const response = await fetch(basepath+page);
container.innerHTML = await response.text();
}
baseContainer.href = basepath;
scriptContainer = document.getElementById('scriptToLoad');
if (basepath == "./pages/blogs/"){
const script = document.createElement('script');
script.src = './../blogScript.js';
script.onload = () => blogLoad();
script.onerror = () => {
console.error(`Failed to load script from ${src}`);
};
scriptContainer.appendChild(script);
//scriptContainer.innerHTML = "<script src='blogScript.js'></script>";
}
else {
scriptContainer.innerHTML = "";
}
}
document.addEventListener('DOMContentLoaded',() => {loadPage("./pages/","aboutMe.html")})