Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript persistent variable

Tags:

javascript

I have created a scroll div which works and is fine. However, my boss now wants to give the client the option of turning of the scrolling feature. I have done this with a simple boolean variable, the problem being that the results page, which has the scrolling feature, has several pages and if the user clicks on to the next page the scroll feature is enabled again (scroll_thumb="true"). What is the best way to keep a variable available to several pages in your app? I don't really want to start passing it in the url, or use a hidden form field, is there another way?

This set of pages are running in .net 3.0 framework but are written in classic asp.

Thanks, R.

like image 469
flavour404 Avatar asked Aug 08 '26 20:08

flavour404


2 Answers

Store it in a cookie.

like image 149
Nick Lewis Avatar answered Aug 10 '26 10:08

Nick Lewis


You should use the framework's (ASP, ASP.NET, or whatever web application framework you're using) state mechanisms to maintain this state across pages. Session state or view state (or whatever more modern state mechanism they have now) is what should be used.

Rolling your own state maintenance in your own cookie(s) would be a bad way to go. Let the framework help you manage this (it'll likely use it's own cookie, but that should be more or less transparent to you).

like image 29
Michael Burr Avatar answered Aug 10 '26 11:08

Michael Burr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!