la page ne se recharge que si on clique sur un autre titre
This commit is contained in:
@@ -6,10 +6,13 @@ function clickAction() {
|
||||
}
|
||||
}
|
||||
|
||||
function insert(e) {
|
||||
var pageName = e.target.id;
|
||||
function titleColor(e) {
|
||||
//change the color of the selected title
|
||||
Object.values(page).forEach(e => e.className = "menu");
|
||||
e.target.className = "menu menu_clic";
|
||||
}
|
||||
|
||||
function loadContent(pageName) {
|
||||
/*next lines changes the script that load different
|
||||
contents for different pages*/
|
||||
//first remove the old one
|
||||
@@ -19,9 +22,20 @@ function insert(e) {
|
||||
var scriptAdd = document.createElement('script');
|
||||
scriptAdd.type = 'text/javascript';
|
||||
scriptAdd.id = "pageScript";
|
||||
scriptAdd.defer = true;
|
||||
scriptAdd.src = 'javascript/' + pageName + '.js';
|
||||
scriptAdd.defer = true;
|
||||
document.head.appendChild(scriptAdd);
|
||||
}
|
||||
|
||||
function insert(e) {
|
||||
//get the name of the page after the # in the url
|
||||
// var nameCompare = location.hash.slice(1);
|
||||
var pageName = e.target.hash.slice(1);
|
||||
|
||||
if (!document.getElementById("pageScript").src.includes(pageName)) {
|
||||
titleColor(e);
|
||||
loadContent(pageName);
|
||||
};
|
||||
}
|
||||
|
||||
clickAction();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var content = document.getElementById("ateliers");
|
||||
var js = document.getElementById("js");
|
||||
|
||||
var ateliers =
|
||||
`
|
||||
<div id="Container">
|
||||
|
||||
Reference in New Issue
Block a user