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 27 28 29 30 31 32 33 34
|
const url = []
exports.addUrl = function (route) {
url.push({state : window.history.state , lien : route})
}
exports.goBack = function () {
for (let index = 0; index < url.length; index++) {
if (url[index].state.page == window.history.state.page) {
if(index > 0){
window.history.pushState(url[index-1].state,'page',url[index-1].lien)
return
}else{
window.history.pushState({page : 'page1'},'page','/')
}
}
}
}
exports.goForward = function () {
for (let index = 0; index < url.length; index++) {
if (url[index].state.page == window.history.state.page) {
if(index < url.length-1){
window.history.pushState(url[index+1].state,'page',url[index+1].lien)
return
}else{
//window.history.pushState(url[index].state,'page',url[index].lien)
}
}
}
} |
Partager