Solved

Javascript: access parent's frame

Posted on 2001-07-20
9
262 Views
Last Modified: 2010-05-18
This should be easy:

My index.html file:

<FRAMESET rowS="*,*">
  <Frame NAME="menu" SRC="menu.html" >
  <FRAMESET colS="*,*" title="bottomframe">
    <Frame NAME="display" SRC="file1.html">
    <Frame NAME="notepad" SRC="file2.html">
  </FRAMESET>
</FRAMESET>

In the "menu.html" file, I want to access the frame (either frame "display) with the following code:

    parent.display.document.location="..."

but it won't work.

What did I miss here ?

As I know, FRAMESET doesn't have a "name" property, and the property "title" failed to function in the following example:

    parent.bottomframe.display.document.location="..."



0
Comment
Question by:shapeless
  • 4
  • 3
  • 2
9 Comments
 
LVL 12

Expert Comment

by:ahosang
ID: 6303039
Your code should work. How are you calling this statement? More code please.
0
 

Author Comment

by:shapeless
ID: 6303494
in script:

1.function WriteMessage()
2.{
3.  alert("test1");    
4.  parent.menu.document.location="http://...";
5.  alert("test2");
6.  parent.display.document.location="http://...";
7.  parent.notepad.document.location="http://...";
8.  alert("test3");
9.}

in HTML:

<input type="button" onclick="WriteMessage();" value="Write">

Action:

When I clicked on the buttom [Write], the frame "menu" loaded a new page as expected. The "alert" function showed "test1", "test2", but not "test3". And neither the frame "display" or "notepad" loaded a new page (nothing happened).

Obviously, the function WriteMessage() was executed, and stopped between line 5~6.
0
 
LVL 12

Expert Comment

by:ahosang
ID: 6304514
Maybe try to load the menu frame last since that is the script calling frame. It seems a weird timing issue, it works on my computer(IE 5.5 and NS 4.6), but maybe it stops because the script calling frame is being wiped out first. The syntax is OK though.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 3

Expert Comment

by:Sendoh
ID: 6307036
yo !!
think this will work....
at least for my case...:P

function goTop(url)
{
     if(parent.location != document.location)
          parent.location = url;
}

hope it helps...:)
0
 

Author Comment

by:shapeless
ID: 6307166
ahosang:

My original code of WriteMessage() was like this:

1.function WriteMessage()
2.{
3.  parent.display.document.location="http://...";
4.  parent.notepad.document.location="http://...";
5.}

That means, it didn't even have the line for menu. I added that and other "alert" statements just to debug.

Sendoh,

I believe that your code actually loads the new page to replace the entire page (parent), but doesn't load the new page to frame "display" or frame "notepad"(which is what I want). Do I miss something here?
0
 
LVL 3

Accepted Solution

by:
Sendoh earned 50 total points
ID: 6307189
ops...
i read the question wrongly...:P
anyway, try this

1.function WriteMessage()
2.{
3.  parent.frames["display"].document.location="http://...";
4.  parent.frames["notepad"].document.location="http://...";
5.}

it should work...;)

hope it helps.

regards
Sendoh
0
 

Author Comment

by:shapeless
ID: 6307201
ahosang:

My original code of WriteMessage() was like this:

1.function WriteMessage()
2.{
3.  parent.display.document.location="http://...";
4.  parent.notepad.document.location="http://...";
5.}

That means, it didn't even have the line for menu. I added that and other "alert" statements just to debug.

Sendoh,

I believe that your code actually loads the new page to replace the entire page (parent), but doesn't load the new page to frame "display" or frame "notepad"(which is what I want). Do I miss something here?
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6307220
?? how come u post the comment 2 times ??
haha
0
 

Author Comment

by:shapeless
ID: 6309025
Dear Sendoh,

I apologize for the duplicate posting. I have no idea how it happened. Most probably I hit a [back] button on the browser and the page was refreshed ....

But anyway your answer works nicely. Thanks a lot ... ;)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

828 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