Document Write to other frame

Discussion in 'Javascript' started by Bruce, Jul 3, 2004.

  1. Bruce

    Bruce Guest

    I have sucessfully used document.write in a new window, but I now wish
    to write to an already open & framed window. How do I do it. Please
    show example, as I have trouble getting my head around JS.

    TIA

    Bruce
    Bruce, Jul 3, 2004
    #1
    1. Advertising

  2. Bruce

    Myron Turner Guest

    You have to use the document object of the window into which you want
    to write. So, assume you have two frames, frame_1 and frame_2 and
    want to write from frame_1 to frame_1. You do as follows:

    top['frame_1'].document.write("text to write").

    top refers to the topmost or parent window, in which you have your
    frameset tags.

    Myron Turner
    On 2 Jul 2004 22:06:45 -0700, (Bruce)
    wrote:

    >I have sucessfully used document.write in a new window, but I now wish
    >to write to an already open & framed window. How do I do it. Please
    >show example, as I have trouble getting my head around JS.
    >
    >TIA
    >
    >Bruce


    Myron Turner
    www.room535.org
    Myron Turner, Jul 3, 2004
    #2
    1. Advertising

  3. Bruce

    Bruce Guest

    (Myron Turner) wrote in message
    > top['frame_1'].document.write("text to write").


    Many thanks for your solution. It basically worked until I moved it
    one more step into the eventual application. It is best to describe
    everything using fruit/vegetables, so here goes ...

    Apple spawns frames Banana & Cherry. Banana is an index, Cherry is
    currently a simple list (it will eventually become an active clickable
    list). When a user clicks on links in Banana, Banana creates Cherry by
    means of "document.write"s. This is now working fine, thanks.

    The "top['frame_1'].doc..." solution works when Apple is the
    controlling page, however Javascript is like a minefield - one step at
    a time. When I moved Apple/Banana/Cherry into a current system, Date
    (the fruit), I got an error. Date opens Apple as a new window. The
    "top['frame_1'].doc..." hint I found now to cause an error, so I tried
    "parent" in place of "top". If IE6 starts cold (ie after a reboot or
    after being closed for a few minutes), I get the error "parent... is
    not an object". The hierarchial & action structure is:
    Date
    Apple
    Banana >> Cherry

    What do I need to do to avoid this error? This is the immediate
    problem, but I also forsee a future problem ...

    Eventually the system will comprise of the following:

    Date (the fruit) is the main page. It can, as one of its clickable
    links, open up, as a new window Apple, which spawns frames Banana
    (index), Eggplant (a details page with nothing clickable), and Cherry
    (a sub-index created by Banana). Eggplant already exists and is
    working properly and is currently controlled by a framed page to be
    merged with Banana. Cherry (the doc.write created document) will have
    clickable links that will do the following:
    1) Show details in Eggplant by means of html <a> (anchor) tags. No
    problems expected.
    2) Scroll the index Banana to show the clicked item at the top. Not
    coded yet, but I expect no problems. I would probably use
    "document.goto", but I have not tried that as yet. A reader may wish
    to give an example of document.goto usage with another framed window.
    3) This is the expected problem: Banana is then expected to recreate
    Cherry, thus destroying the document that caused it to act. And how do
    I call a function in another framed document?

    The hierarchial & action structure will eventually be:
    Date
    Apple
    Eggplant & Banana >> Cherry (click)>> Eggplant & Banana >> Cherry.

    Is this all possible, or have I become too attached to
    fruit/vegetables and should stick to minerals?

    In summary two problems:
    P1: The error "parent... is not an object".
    P2: Will there be an issue having a calling document being destroyed
    before the call is returned. And how do I call a function in another
    framed document?

    TIA

    Bruce
    (Fruit/Vege Fanatic)

    Footnote:
    The problem does not seen to occur in XP/IE6, but in 98/IE6. I am
    still trying to get the error under XP/IE6. The code has not been
    changed.
    Bruce, Jul 8, 2004
    #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. imaband
    Replies:
    5
    Views:
    99
    CodeHopper
    Nov 16, 2004
  2. Replies:
    2
    Views:
    189
  3. Jim Cobban
    Replies:
    0
    Views:
    118
    Jim Cobban
    Jul 31, 2005
  4. jullag
    Replies:
    20
    Views:
    304
    Frances
    Sep 22, 2005
  5. '69 Camaro
    Replies:
    8
    Views:
    195
    Randy Webb
    Jan 13, 2006
Loading...

Share This Page