After I ask this question
:
I was thinking about this solution:
- Create a boolean flag inside the javascript script and make it true:
- true indicates refreshing the page using the browser.
- false indicates refreshing the page using a button.
- Inside onclick attribute of the button, I set flag to false and call
window.location.reload()
to refresh the page. - Inside onload attribute of
<body>
tag, I check the flag if it's true switch toHome
tab else switch toPage1
tab where it contains the<div>
tag I want to refresh its contents. After that, set flag to true.*
But unfortunately it doesn't work and flag
is always true when it comes to onload attribute of <body>
tag. Is it possible (somehow) to create a variable, that doesn't change on refresh the page, in javascript?
*My page consistes of many tabs, first one is Home (where it should be shown when refreshing the page using the browser) and second one is Page1 (where it contains the <div>
tag I want to refresh its contents and where it should be shown when refreshing the page using the button)