Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6377795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:55:16+00:00 2026-05-25T01:55:16+00:00

After I ask this question : I was thinking about this solution: Create a

  • 0

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 to Home tab else switch to Page1 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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:55:17+00:00Added an answer on May 25, 2026 at 1:55 am

    The browser is stateless, which means that everything on the page is refreshed each time the page loads.

    There are a few ways to store persistant information that you can access between requests:

    • Store the data you want in a cookie and read it when the page loads
    • Pass data to the URL and read the current URL (including the data that you passed) when the page loads. For example: Redirect the browser to http://something.com/yourpage.html#flag=true if the user refreshed through the browser or redirect to http://something.com/yourpage.html#flag=false if the user clicked the button. On the onload of the page just read the current URL and see what the flag is.
    • Use a cookie to create a session and store data on the server (technically this is very similar to the first option except you just store a token on the client and pass it to the server to retrieve data that was stored there)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ask this question because I've implemented a javascript solution to nested inlines (it
After looking at stackoverflow and many other forums, decided to ask this question. The
I'm embarrassed to ask this question, but after 45 minutes of not finding a
I guess it's a bit rude to ask this question, as I should make
I ask this not to start anything negative. Rather, after looking at ASP.NET MVC
After reading an article about the subject from O'Reilly , I wanted to ask
After reading this question , I was reminded of when I was taught Java
I ask this question, since I am trying to get the images I have
After googling and binging for a whole day about this, and even trying some
I'm not sure how to ask this question, but here goes... I am rendering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.