By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,784 Members | 1,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,784 IT Pros & Developers. It's quick & easy.

pass variables from one page to another in same window

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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"

Jul 23 '05 #2

P: n/a

"Lee" <RE**************@cox.net> wrote in message
news:c9*********@drn.newsguy.com...
Andy Fish said:

Hi,

I have a javascript solution where page A launches page B in a second windowand 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 pageB 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 loadingC, 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.


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
Google for "pass values pages javascript"

Jul 23 '05 #3

P: n/a
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.

Jul 23 '05 #4

P: n/a
Andy Fish wrote:
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
Jul 23 '05 #5

P: n/a

"Lee" <RE**************@cox.net> wrote in message
news:c9*********@drn.newsguy.com...
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 withmy 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.


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
Jul 23 '05 #6

P: n/a
I'm curious what your solution is for the simple example, since it
doesn't appear that you use cookies, frames or forms. Please let me know.

Amy

Andy Fish wrote:
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


Jul 23 '05 #7

P: n/a
"Andy Fish" <aj****@blueyonder.co.uk> wrote in message news:<i8*********************@news-text.cableinet.net>...
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.
Jul 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.