Solved

Javascript: access parent's frame

Posted on 2001-07-20
9
257 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript/Java - Changing an image background color 4 67
check java version using powershell 13 93
servlet example 17 32
mysql jsp example issue 32 38
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

809 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