Document.write in parent.frame

Hi Experts,

I have the following challenge:

Imagine :
A page with 3 frames
- Left
- Middle
- Right

On the middel frame it can happen that a link is clicked that requires to create the whole frame again (with some variable links)
So I thought I write the complete frame with something like:
      parent.frame1.Document.clear()
      parent.frame1.Document.open()
      parent.frame1.Document.write("Line1")
      parent.frame1.Document.clear("Line2")
      parent.frame1.Document.close()

But I'm afraid thet the "Clear" statment erase the whole frame including the rest of my script.
If I remove the "parent.frame1" part, the required information is written to the Middelframe,
so the script is writinng what is must do, but not in the right frame,
How can I solve this.
Is it possible to create a new page in memory and assign it to the parent.frame








LVL 17
MurpheyApplication ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cubrovicCommented:
Try
parent.frame1.document.body.innerHTML = "line1"

that will change just the content of your body
0
cubrovicCommented:
Try
parent.frame1.document.body.innerHTML = "line1"

that will change just the content of your body
0
MurpheyApplication ConsultantAuthor Commented:
Hi cubrovic,

No, same result!!!

I will explain a little more,
We have the posibility to put a page on the site of one of our patners, this site has a Top, center and bottom frame.
When you click on some link in the top frame, our page is shown in the centerframe.
Our main page is also build in 3 frames left middle and right.
If I click on a specific link, our whole page must be replaced by an other page, with some variable elements, so I like to create it instead of link to it (that would be easy).
I can do what I like as long as the top and bottom frame of our partners site will be remain visible.

0
cubrovicCommented:
You cant replace all you contents of your top frame (middle frame of your partner) with new content and make your exeisting scripts stay.(as far as i know)

But this is what you can do about this.
Move all your scripts (function definitions ...) to the separate .js file and then you include it in your .html files via the script.
When you generate your new page from the script via the
document.clear  document.write
you can send your scripts to the generated window like this


js = '<scr'+'ipt language="javascript"  '
js+= ' type="text/javascript" ><\/scr'+'ipt>'

parent.frame1.Document.clear()
parent.frame1.Document.open()
parent.frame1.Document.write(js)
parent.frame1.Document.write("other html or txt")
parent.frame1.Document.close()


Now little explanation about code above.
If  you have noticed '<scr'+'ipt ..
and dont now why is that, that is because most browsers have strange but expected reaction if they find tag <script > in one place so we have to break.

This is enough if you just want to pass your js functions but if you want to pass to the new window in the number of ways.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MurpheyApplication ConsultantAuthor Commented:
Hey Thats sneaky !!!!

Great It works Thanks !!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.