Jump to content

Persistent vars?


davej

Recommended Posts

Most of the JS I have written have been event-driven validators and I am curious if it is possible to save variable values while the code is not executing? I mean if you use window.onload to set up some values and then later an onclick event fires some code that needs those values. How can that be done? Are there several options? I see that I can assign values to hidden HTML fields to accomplish this but that seems a little hokey. Thanks.

Link to comment
Share on other sites

Global variables (ones that are declared outside of any function, or are added as a property of the window object) are always available at any time.

Link to comment
Share on other sites

Global variables (ones that are declared outside of any function, or are added as a property of the window object) are always available at any time.
Oops. I thought I had tested that but apparently not correctly. Thanks.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...