This is possible to using cookies, localStorage or sessionStorage etc.
We can use localStorage for it. we need to set a varibale that should be reflected in next pages or after reload the page.
eg.:
var myval = "xyz";
localStorage.setItem("myval", myval);
after that we can get the stored value from localStorage by page reloaded/Refresh...
like:
var...