Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > pass variables from one page to another in same window

Reply
Thread Tools

pass variables from one page to another in same window

 
 
Andy Fish
Guest
Posts: n/a
 
      06-03-2004
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


 
Reply With Quote
 
 
 
 
Lee
Guest
Posts: n/a
 
      06-03-2004
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"

 
Reply With Quote
 
 
 
 
Andy Fish
Guest
Posts: n/a
 
      06-03-2004

"Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>


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"
>



 
Reply With Quote
 
Lee
Guest
Posts: n/a
 
      06-03-2004
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.

 
Reply With Quote
 
Mick White
Guest
Posts: n/a
 
      06-03-2004
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
 
Reply With Quote
 
Andy Fish
Guest
Posts: n/a
 
      06-03-2004

"Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>


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


 
Reply With Quote
 
bruce
Guest
Posts: n/a
 
      06-11-2004
"Andy Fish" <(E-Mail Removed)> wrote in message news:<i8Ivc.3213$(E-Mail Removed)>...
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
session variables - how to handle parallel access by the same user tothe same page Stephan Steiner ASP .Net 1 09-24-2009 03:10 AM
how to pass values from one page to another page in xbap ravikumar.annama@gmail.com ASP .Net Web Services 1 09-29-2008 03:06 PM
pass cookie from one domain to another on the same server c676228 ASP General 13 01-30-2008 06:44 AM
How to pass value of one page to another page Rabbit ASP .Net 17 06-11-2006 05:49 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments