?
Solved

Document.write in parent.frame

Posted on 2003-03-13
5
Medium Priority
?
527 Views
Last Modified: 2012-06-21
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








0
Comment
Question by:theo kouwenhoven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:cubrovic
ID: 8129228
Try
parent.frame1.document.body.innerHTML = "line1"

that will change just the content of your body
0
 
LVL 7

Expert Comment

by:cubrovic
ID: 8129466
Try
parent.frame1.document.body.innerHTML = "line1"

that will change just the content of your body
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 8136058
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
 
LVL 7

Accepted Solution

by:
cubrovic earned 200 total points
ID: 8138654
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 8142843
Hey Thats sneaky !!!!

Great It works Thanks !!!!
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question