Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Javascript: access parent's frame

Posted on 2001-07-20
9
Medium Priority
?
279 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
[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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

670 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