pass variables from one page to another in same window

A

Andy Fish

Hi,

I have a javascript solution where page A launches page B in a second window
and then they can pass data between them. That's all well and good.

Now say page B wants to navigate to page C (i.e. in the same window as page
B is currently in, and I want to pass information from B to C.

Currently I have it that B passes the information back to A before loading
C, and C then picks it up from A.

Any easier way to do this? it must be wholly client side and not
browser-specific.

Many thanks,

Andy
 
L

Lee

Andy Fish said:
Hi,

I have a javascript solution where page A launches page B in a second window
and then they can pass data between them. That's all well and good.

Now say page B wants to navigate to page C (i.e. in the same window as page
B is currently in, and I want to pass information from B to C.

Currently I have it that B passes the information back to A before loading
C, and C then picks it up from A.

Any easier way to do this? it must be wholly client side and not
browser-specific.

That's what cookies are for.

If you can't rely on cookies being enabled, you can encode values
in the URL of page C by appending a "?" followed by your information:

location="http://myserver/pageC.html?John+Smith";
or
location="http://myserver/pageC.html?a=47&b=28&id=John+Smith";

Your pageC.html contains code to parse the data out of location.search.

Google for "pass values pages javascript"
 
A

Andy Fish

Lee said:
Andy Fish said:

That's what cookies are for.

If you can't rely on cookies being enabled, you can encode values
in the URL of page C by appending a "?" followed by your information:

location="http://myserver/pageC.html?John+Smith";
or
location="http://myserver/pageC.html?a=47&b=28&id=John+Smith";

Your pageC.html contains code to parse the data out of location.search.

Thanks lee. Unfortunately I need to pass some nested structures around
rather than a couple of simple values, so I think I will probably stick with
my original idea.

At least I know I wasn't missing out on anything obvious
 
L

Lee

Andy Fish said:
Thanks lee. Unfortunately I need to pass some nested structures around
rather than a couple of simple values, so I think I will probably stick with
my original idea.

There are other options that amount to only replacing the visible
part of pageB with the visible part of pageC, by changing the
contents of a container such as an iframe.

If you're passing structures, then you're probably actually passing
references to them, which means that if the page that contains the
original data is closed, the other pages won't be able to access it.
That may not be a problem if that original page is vital, anyway.
 
M

Mick White

Andy said:
Hi,

I have a javascript solution where page A launches page B in a second window
and then they can pass data between them. That's all well and good.

Now say page B wants to navigate to page C (i.e. in the same window as page
B is currently in, and I want to pass information from B to C.

Currently I have it that B passes the information back to A before loading
C, and C then picks it up from A.

Any easier way to do this? it must be wholly client side and not
browser-specific.

Many thanks,

Andy
You could use frames, one of them invisible where you could keep track
all of your scripted elements.

Mick
 
A

Andy Fish

Lee said:
Andy Fish said:


There are other options that amount to only replacing the visible
part of pageB with the visible part of pageC, by changing the
contents of a container such as an iframe.

If you're passing structures, then you're probably actually passing
references to them, which means that if the page that contains the
original data is closed, the other pages won't be able to access it.
That may not be a problem if that original page is vital, anyway.

The main form (form A) is really a controlling window. although there's no
real concept of modal windows, the other window be modal if it were a VB
app, so I don't it's too much of a hack passing all the data back through
the main form.

Good idea about the frameset though - I will certainly try that if I get
into a similar situation wuthout having a separate main window to fall back
on.

cheers

Andy
 
B

bruce

Andy Fish said:
Hi,

I have a javascript solution where page A launches page B in a second window
and then they can pass data between them. That's all well and good.

Now say page B wants to navigate to page C (i.e. in the same window as page
B is currently in, and I want to pass information from B to C.

Currently I have it that B passes the information back to A before loading
C, and C then picks it up from A.

Any easier way to do this? it must be wholly client side and not
browser-specific.

Many thanks,

Andy


Too lazy to view the whole thread, but did anyone suggest an
invisible frame, or iframe to store such data. We're lucky here, our
app always has a left-side menu frame which shows, so information can
be stored in this frame, while the right side frames change and pick
up such information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top