So, I just want to define some variables, and change their value according to the user action(page visit)
script_variables.js
var visitedPage1 = 0 ;
var visitedPage2 = 0;
var visitedPage3 = 0;
script_home.js
window.onload = function() {
console.log(visitedPage1);
}
Page1.html
<script src="/js/script_variables.js"></script>
<script>
window.onload = function() {
visitedPage1 = 1;
}
Home.html
<script src="/js/script_variables.js"></script>
<script src="/js/scriptHome.js"></script>
Even though, I can change assign 1 into visitedPage1, when I came back to the home, console shows 0, I guess it reloads the script_variable.js again and assign 0.
How should I approach this problem and sorry for this noob question. thank you