global variable in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunnypirate
    New Member
    • Aug 2009
    • 5

    global variable in javascript

    I wanted to use a global array that can be used on any page that uses the array..

    Right now the array gets reset when I load a new page.. or refresh the current page.

    What is the solution for this? I cannot use a database.. Also is an external js file a solution??

    Thanks,
    Sunny
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    a global javascript variable lives as long as the window isn't reloaded ... do you want to have it persistent between the pageloads or is it a kind of constant?

    Comment

    • sunnypirate
      New Member
      • Aug 2009
      • 5

      #3
      Thanks for the reply.
      I am adding data to array as user clicks on a link.. I want the array to retain these values even if the page reloads.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        then you would need to use a cookie ... have a look here to get you started

        kind regards

        Comment

        Working...