I am beginner to JavaScript. I am opening a html page, whose JavaScript file has a global variable token
.
In the JavaScript file, I am opening another html link on some condition using the code:
if(data.status==="Success"){
window.open("http://172.19.101.65:8001/","_self")
}
Now in the JavaScript file of the above html link, whichever is loaded, I am not able to access the value token through window.token
.
I am not sure whether my approach is right or wrong. I would be thankful for the help.
You can use local storage: Work across pages
Set item: localStorage.setItem('token','value')
Get Item : localStorage.getItem('token')
PS: You can also use a cookie. Suitable and supported on almost every browser ;)