variable from another frame/page

Discussion in 'Javascript' started by Alex Hunter, Oct 15, 2003.

  1. Alex Hunter

    Alex Hunter Guest

    Is it possible for one page to access a variable (or text) from another page
    or frame? How is this done?

    I want to update a piece of data on one page, and have it update on lots of
    different pages. I thought I could define the data as a variable on one
    page, and have all the other pages look at and display the variable from that
    page. Both pages could be open in a frameset. I have no idea how to do this,
    Is it possible? Could a javascript access a text file on the server and post
    this into a page? Any ideas?

    thanks,
    Alex Hunter
    Alex Hunter, Oct 15, 2003
    #1
    1. Advertising

  2. Alex Hunter <> writes:

    > Is it possible for one page to access a variable (or text) from another page
    > or frame?


    Yes, if you have a reference to the other page (or frame, but frames
    are easy to get a reference to if you are in the same window).

    > How is this done?


    Try reading this:
    <URL:http://www.infimum.dk/HTML/JSwindows.html#ref_2_6>
    I hope it is informative enough.

    > Both pages could be open in a frameset. I have no idea how to do this,


    Having two frames, or accessing data across them?

    > Is it possible?


    Absolutely.

    > Could a javascript access a text file on the server and post
    > this into a page? Any ideas?


    That is harder. Not all browsers have an easy way to access an
    arbitrary file on the server. One solution is to load the file into a
    hidden iframe and then use DOM methods to extract the text.

    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Oct 15, 2003
    #2
    1. Advertising

  3. Alex Hunter

    Alex Hunter Guest

    thanks for the informitave link. I've got it somewhat, but I am still having
    some problems.

    I made a test page with two frames. The top frame defines three variables,
    and the botom frame retrives these variables from the other frame and
    displays them. here is the test page:
    http://alex.hunter.home.comcast.net/test

    It works sometimes, but other times the variables show up as "undefined" on
    the bottom frame. reloading the page cycles it between working and not
    working. Does anyone have any ideas why it would only work sometimes? I
    have tested on Mac OS X with IE and netscape.

    any feedback would be apreciated.

    thanks,
    Alex Hunter




    On Wed, 15 Oct 2003 18:21:41 -0400, Lasse Reichstein Nielsen wrote
    (in message <>):

    > Alex Hunter <> writes:
    >
    >> Is it possible for one page to access a variable (or text) from another
    >> page
    >> or frame?

    >
    > Yes, if you have a reference to the other page (or frame, but frames
    > are easy to get a reference to if you are in the same window).
    >
    >> How is this done?

    >
    > Try reading this:
    > <URL:http://www.infimum.dk/HTML/JSwindows.html#ref_2_6>
    > I hope it is informative enough.
    >
    >> Both pages could be open in a frameset. I have no idea how to do this,

    >
    > Having two frames, or accessing data across them?
    >
    >> Is it possible?

    >
    > Absolutely.
    >
    >> Could a javascript access a text file on the server and post
    >> this into a page? Any ideas?

    >
    > That is harder. Not all browsers have an easy way to access an
    > arbitrary file on the server. One solution is to load the file into a
    > hidden iframe and then use DOM methods to extract the text.
    >
    > /L
    >
    Alex Hunter, Oct 16, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Søren M. Olesen
    Replies:
    0
    Views:
    566
    Søren M. Olesen
    Nov 13, 2003
  2. Microsoft
    Replies:
    3
    Views:
    683
    Hugo Wetterberg
    Oct 4, 2004
  3. Noozer
    Replies:
    0
    Views:
    2,986
    Noozer
    Oct 22, 2005
  4. Zalek Bloom
    Replies:
    1
    Views:
    205
    Aaron Bertrand - MVP
    Sep 23, 2003
  5. Rob
    Replies:
    11
    Views:
    206
Loading...

Share This Page