This is a demo link to one of my page
Here you will see two divs… The upper one and the lower one. When a user logins, he sees both the div open. On his wish, he can close the upper div. I am using a simple script for it. When the user refreshes the page, both div comes open again. No hiding option is there for second one.
Here my requirement changes now.
I want that instead of hide option, the user should be able to lock the upper div by clicking there.when he refreshes that div sholdnot open itself. A user should click it to unlock it. but once he closes the page or logs out… He should both the divs open. I am new but i know there are many genius who can do this. Please help me.
Can you show us what you’ve tried so far? We’re happy to help if you get stuck, but we’re not here to do your work for you.
Hi… I need the way to achieve it, more precisely suggestions. I am not asking for the script this time…
After someone tell me the way and ideas, i will try to implement it and if got stuck will reach here again.
I too dont want to copy someone else’s work and hardwork. But yes, i expect their guidance.
To be honest I don’t find your post too clear, but it sounds like you want users to click a div, and then the div should remember the state of being locked/unlocked for that session. So if you lock it and reload it stays locked, etc.
What you’re looking for here is
sessionStorage. See http://www.nczonline.net/blog/2009/07/21/introduction-to-sessionstorage/
What you do is you store the value of locked/unlocked in the
sessionStorage, and when the page reloads you check the
sessionStorage what the state should be and apply it. When a user logs out you reset the
sessionCache to the the div to show, so when they log in again the div will be visible. You don’t need to anything special for when a user closes the tab, because the browser will automatically delete all items in
sessionStorage when a user closes the tab/window.
session storage only exists for the duration of the session.
If they want it to remember the setting after the browser is closed then they’ll need to use localStorage instead.
But i think that method will not work for the users who are using unsupported browsers for this.
In which case you could use a cookie instead. The only difference being that the cookie gets passed to the server as well.