I need to refer a global variable across multiple html files,each of the multilpe html file is referring to a common js file.
index.html sub1.html sub2.html
in each of the html pages the js is included in the head tag
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="/css/Main.css" type="text/css"/>
<script src="/js/Main.js" ></script>
</head>
Navigation from one html to other html is from a js function like.
say from index.html to sub1.html
window.location.href='/forms/sub1.html';
I have declared a global varibale globalCount, to check how many navigations have been done in the global scope of the Main.js
var globalCount=1;
and incremented in the navigation function.
But for each of the html page the globalCount variable is reinitialized to 1, even though the Main.js is NOT downloaded multiple times.
I have tried declaring through window.globalCount, no luck.
Any easy way to have a common global variable across multiple htmls but in the same js file.
Hope you understand the question.