Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Document.write in parent.frame

Posted on 2003-03-13
5
Medium Priority
?
530 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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

580 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