Connecting Tech Pros Worldwide Help | Site Map

pass variables from one page to another in same window

Andy Fish
Guest
 
Posts: n/a
#1: Jul 23 '05
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


Lee
Guest
 
Posts: n/a
#2: Jul 23 '05

re: pass variables from one page to another in same window


Andy Fish said:[color=blue]
>
>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.[/color]

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"

Andy Fish
Guest
 
Posts: n/a
#3: Jul 23 '05

re: pass variables from one page to another in same window



"Lee" <REM0VElbspamtrap@cox.net> wrote in message
news:c9nki502ign@drn.newsguy.com...[color=blue]
> Andy Fish said:[color=green]
> >
> >Hi,
> >
> >I have a javascript solution where page A launches page B in a second[/color][/color]
window[color=blue][color=green]
> >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[/color][/color]
page[color=blue][color=green]
> >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[/color][/color]
loading[color=blue][color=green]
> >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.[/color]
>
> 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.
>[/color]

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
[color=blue]
> Google for "pass values pages javascript"
>[/color]


Lee
Guest
 
Posts: n/a
#4: Jul 23 '05

re: pass variables from one page to another in same window


Andy Fish said:
[color=blue]
>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.[/color]

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.

Mick White
Guest
 
Posts: n/a
#5: Jul 23 '05

re: pass variables from one page to another in same window


Andy Fish wrote:
[color=blue]
> 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
>
>[/color]
You could use frames, one of them invisible where you could keep track
all of your scripted elements.

Mick
Andy Fish
Guest
 
Posts: n/a
#6: Jul 23 '05

re: pass variables from one page to another in same window



"Lee" <REM0VElbspamtrap@cox.net> wrote in message
news:c9noua02vm6@drn.newsguy.com...[color=blue]
> Andy Fish said:
>[color=green]
> >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[/color][/color]
with[color=blue][color=green]
> >my original idea.[/color]
>
> 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.
>[/color]

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


Amy Johnson
Guest
 
Posts: n/a
#7: Jul 23 '05

re: pass variables from one page to another in same window


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:[color=blue]
> 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
>
>[/color]

bruce
Guest
 
Posts: n/a
#8: Jul 23 '05

re: pass variables from one page to another in same window


"Andy Fish" <ajfish@blueyonder.co.uk> wrote in message news:<i8Ivc.3213$hg1.32192585@news-text.cableinet.net>...[color=blue]
> 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[/color]


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.
Closed Thread