pass variables from one page to another in same window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Fish

    #1

    pass variables from one page to another in same window

    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

    #2
    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+S mith";

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

    Google for "pass values pages javascript"

    Comment

    • Andy Fish

      #3
      Re: pass variables from one page to another in same window


      "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
      news:c9nki502ig n@drn.newsguy.c om...[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+S mith";
      >
      > 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]


      Comment

      • Lee

        #4
        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.

        Comment

        • Mick White

          #5
          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

          Comment

          • Andy Fish

            #6
            Re: pass variables from one page to another in same window


            "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
            news:c9noua02vm 6@drn.newsguy.c om...[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


            Comment

            • Amy Johnson

              #7
              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]

              Comment

              • bruce

                #8
                Re: pass variables from one page to another in same window

                "Andy Fish" <ajfish@blueyon der.co.uk> wrote in message news:<i8Ivc.321 3$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.

                Comment

                Working...