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) {
|
function titleColor(e) {
|
||||||
var pageName = e.target.id;
|
//change the color of the selected title
|
||||||
Object.values(page).forEach(e => e.className = "menu");
|
Object.values(page).forEach(e => e.className = "menu");
|
||||||
e.target.className = "menu menu_clic";
|
e.target.className = "menu menu_clic";
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadContent(pageName) {
|
||||||
/*next lines changes the script that load different
|
/*next lines changes the script that load different
|
||||||
contents for different pages*/
|
contents for different pages*/
|
||||||
//first remove the old one
|
//first remove the old one
|
||||||
@@ -19,9 +22,20 @@ function insert(e) {
|
|||||||
var scriptAdd = document.createElement('script');
|
var scriptAdd = document.createElement('script');
|
||||||
scriptAdd.type = 'text/javascript';
|
scriptAdd.type = 'text/javascript';
|
||||||
scriptAdd.id = "pageScript";
|
scriptAdd.id = "pageScript";
|
||||||
scriptAdd.defer = true;
|
|
||||||
scriptAdd.src = 'javascript/' + pageName + '.js';
|
scriptAdd.src = 'javascript/' + pageName + '.js';
|
||||||
|
scriptAdd.defer = true;
|
||||||
document.head.appendChild(scriptAdd);
|
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();
|
clickAction();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
var content = document.getElementById("ateliers");
|
var content = document.getElementById("ateliers");
|
||||||
var js = document.getElementById("js");
|
var js = document.getElementById("js");
|
||||||
|
|
||||||
var ateliers =
|
var ateliers =
|
||||||
`
|
`
|
||||||
<div id="Container">
|
<div id="Container">
|
||||||
|
|||||||
Reference in New Issue
Block a user