Document Write to other frame

B

Bruce

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
 
M

Myron Turner

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

Bruce

(e-mail address removed) (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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top