Click to See Complete Forum and Search --> : Passing variables between pages


stmasi
05-28-2003, 01:17 PM
Is there any way to pass variables between two different pages?

I'll set the variable in page1.html and then, using the meta refresh command, I'll replace it with page2.html.

Once I've done that, the variable set in page1.html has returned to the infamous, "unassigned" status.

Thanx.

Gollum
05-28-2003, 01:30 PM
Strictly, the answer is ... No!

All Javascript variables are lost when a new page loads. The browser wipes the whole slate clean and starts afresh with the new page - this is actually a good thing - who knows what state a browser could get into in previous sites before it comes to yours...

The typical way to pass information from one page to another is either via posting form information or by using request parameters (putting stuff in the url e.g. showthread.php?s=&threadid=10253)

pyro
05-28-2003, 01:31 PM
Use a query string, like this: page2.html?yourvariable

and then use top.location.search.substr(1) to parse it off...

AdamGundry
05-28-2003, 01:31 PM
You can pass data on the URL (HTTP GET data) then read it into Javascript variables using a script like this:
http://www.agbs.co.uk/scripts/get_extract.html

You should be able to pass the value with something like this (Javascript):
window.location = 'http://www.example.com/page2.html?variablename=value&var2=value2';

Adam

stmasi
05-28-2003, 02:42 PM
Cool.

Now, is there any way to do this without using any javascript or forms?

THanx.

pyro
05-28-2003, 03:08 PM
You could do it server side, with PHP (or others)...