Passing variables between HTML pages using Javascript

Can someone please tell me how to pass variables between pages using Javascript. For example if i define a variable "Score" in a file called 'page1.html' how can I get that variable into 'page2.html'.
Who is Participating?
rviswaConnect With a Mentor Commented:
If you want a secure transmission of data, then you should POST the form. So that the values will be sent in the HEADER. If the site is UNSECURED, you can pass the value using QueryString.

Now, to answer your question: Use a HIDDEN text box in the first form and update the variable's value in it. When you POST this form and loading the next PAGE( for example Page2.asp), you can get this value from Request.Form().

This WILL work. Let me know how it is going. Have fun.
you might have to use a CGI program of some kind to act as a glue between these pages. Without this glue both these HTML files are 2 individual documents without any way to talk toeach other.

i dont think javascript would work as that glue here.
If there i not very much variabels, you can use "cookies".
See javascript, for "copy/paste"ecxamples!!

Never miss a deadline with

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

You could also pass information in the URL, although I'm not sure how many browsers support this for client side JavaScript.
Using is supported since javascript 1.0, so that would be netscape 2.0 and IE 3.0.  To send the info this way you'd need to pass it like this:

Then in the receiving page,
Score =; // grabs the search string
Score = unescape(Score.substring(1)); // removes the ? at the beginning, and unescapes the variable

To use cookies is a little more complex, but is more behind the scenes (the search way shows up in the location bar where the user can see the value getting sent)

If you want code for passing parameters using, check out PAQ 
All Courses

From novice to tech pro — start learning today.