Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Javascript: access parent's frame

Posted on 2001-07-20
9
Medium Priority
?
280 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses

916 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