Solved

loading a url from nested frames popup

Posted on 1998-05-13
11
222 Views
Last Modified: 2008-02-01
I'm posting for a friend... I want to load a url from a popup into another frame.
The initial frameset is split the screen vertically into 3rds. Frames named Left, Middle & Right. The left fame is split in 1/2. The frame names are LeftUpper & LeftLower.The LeftLower frame is the frame I want to launch the popup from. The Middle frame named Middle is not split at all. The Right frame named Right contains a file which loads a new frameset and is split horizontally by  3rds. Named (top to bottom) A,B & C. I want to load frame C with a new URL from the popup. I'm using NN4 but would like a solution to work in IE4 also if possible. I have tried things like opener.frames[2].frames[2].location.href = URL but that doesn't work:( I have also tried opener.frames['LeftUpper'].frames['C'].location.href = URL!!! Nothing seems to work. One final note I need it in location.href=URL format ! I have posted an example of the frame layout  at www.capoeirasj.com/example/setup.html
0
Comment
Question by:sargento
  • 6
  • 5
11 Comments
 

Author Comment

by:sargento
ID: 1278008
Edited text of question
0
 

Author Comment

by:sargento
ID: 1278009
Edited text of question
0
 

Author Comment

by:sargento
ID: 1278010
I put up an additional graphic to help clarify at:
www.capoeirasj.com/example/setup2.html
0
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 220 total points
ID: 1278011
sargento,

Referencing Frames from popup windows is always a tricky one and often needs a lot of thought as to layout.  However, that said I have solved your problem.

What you have to do is give your orginal window (the one which contains all the frames) a name when you open the popup.  To open the popup use this script in your LowerLeft frame:-

<SCRIPT LANGUAGE="JavaScript">
<!--

var newWindow;
winOpts='menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,width=250,height=250';

      self.name = 'opener';
      Urlvar = "popup.html";
      popup = window.open(Urlvar,'newWindow',winOpts);

// --->
</SCRIPT>

Notice the use of self.name = 'opener'; this can be named anything you choose but opener seems logical.  Of course you can turn on or off any of the options and change the window dimensions.

The popup is then launched and in your popup you should have something like this:

<HTML>
<HEAD>
<TITLE>PopUp</Title>
</HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!--

function GoThere() {
   opener.top.Right.C.location.href = "popup.html";
}

// --->
</SCRIPT>

<BODY BGCOLOR=cream><center>
Popup
<BR>

<A HREF="javascript:GoThere();">Link to Frame C</A>
</body>
</html>


Notice here the call to the function which then loads the correct page in the frame 'C' by firsat referencing the opener then the top of that then the Right frame and finally the frame 'C'.

Hope this helps.

Trevor.
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1278012
sargento,

You can of course set up all of your frames using only one frameset.  This would then make things easier when referencing frames as you would only have one level.

Your frameset could then look like this:-

<FRAMESET FRAMEBORDER="no" BORDER=0 COLS="40%,20%,40%">
   <FRAMESET FRAMEBORDER="no" BORDER=0 ROWS="50%,50%">
     <FRAME SRC="LeftUpper.html" NAME="LeftUpper" noresize marginheight=0 marginwidth=0 SCROLLING=AUTO>
     <FRAME SRC="LeftLower.html" NAME="LeftLower" noresize marginheight=0 marginwidth=0 SCROLLING=AUTO>
   </FRAMESET>
   <FRAME SRC="DefaultMiddle.html" NAME="Middle" noresize marginheight=0 marginwidth=0 SCROLLING=AUTO>
   <FRAMESET FRAMEBORDER="no" BORDER=0 ROWS="33%,33%,33%">
     <FRAME SRC="defaultA.html" NAME="A" noresize marginheight=0 marginwidth=0 SCROLLING=AUTO>
     <FRAME SRC="DefaultB.html" NAME="B" noresize marginheight=0 marginwidth=0 SCROLLING=AUTO>
     <FRAME SRC="DefaultC.html" NAME="C" noresize marginheight=0 marginwidth=0 SCROLLING=AUTO>
   </FRAMESET>
</FRAMESET>

You then do not need the 2 pages you currently have called DefaultRight.html and Defaultleft.html which set up your previous framesets.

If you choose this approach you will then need to reference Frame 'C' from the popup using this:

<HTML>
<HEAD>
<TITLE>PopUp</Title>
</HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!--

function GoThere() {
   opener.top.C.location.href = "popup.html";
}

// --->
</SCRIPT>

<BODY BGCOLOR=cream><center>
Popup
<BR>

<A HREF="javascript:GoThere();">Link to Frame C</A>
</body>
</html>


It is exactly the same as before except that the line:

   opener.top.Right.C.location.href = "popup.html";

has changed to:

   opener.top.C.location.href = "popup.html";

Hope this helps.

Trevor.


0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:sargento
ID: 1278013
Trevor I have to digest your answer. I can't use one frameset because different URLs will be loaded in the Right  frame.
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1278014
sargento,

Just thought I'd offer the single framset solution aswell to make my answer complete.

If you have any problems then let me know.

Trevor.

0
 

Author Comment

by:sargento
ID: 1278015
Hi Trevor,
I confused about what you did.
First of all I have all my stuff setup. As far as the popup goes, I just can't get the popup to load the C frame. I guess I should have mentioned that.
Question 1.
You said this function should be in my popup window:


 function GoThere() {
    opener.top.Right.C.location.href = "popup.html";
 }

but what is the popup.html file mentioned? Did you mean the URL to be loaded in frame C?

the second question is:

self.name = 'opener';
 popup = window.open(Urlvar,'newWindow',winOpts);

so in the frame that launches the popup (in this case LeftLower) I should have these lines?
does the self.name name the top frameset even though it is in the LeftLower frame? Also what's the purpose of assigning the whole string to popup?

Thanks:)
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1278016
sargento,

The popup.html in the function is as you correctly stated the name of the file you wish to load in Frame 'C', sorry I named it popup.html, some bizarre logic on my part.

In your frame (Lowerleft) where you launch the popup from you name it using self.name which does name that particular frame and not the top frameset.  This however does not matter (it is the easiest way to do it), it simply gives you a reference in the original window otherwise you have nothing by which to refer to this window.  Once you have given one of the frames a name you can navigate through them as we are doing.

This line:

popup = window.open(Urlvar,'newWindow',winOpts);

simply opens the window.  As you have already got your code to open the window you can probably ignore it, I didn't realise you already had a window open.  All I have done is plit out the various parts of the window opening.

What I have done is defined some variables:

winOpts='menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,width=250,height=250';

self.name = 'opener';
Urlvar = "popup.html";

Which set the options for the window and the URL to load in it and name my current frame.


popup = window.open(Urlvar,'newWindow',winOpts);

This then simply says:

Open the new window.  Load the variable we defined as URLvar, set the windows name as newWindow and then set all the windows options which we have already defined as winOpts.

The popup we have assigned this all to is a variable of the object that opened the newWindow. newWindow is the new window's name.  The new window's properties can be referenced through the varoibale popup. Links and forms can be targeted to the new window with its name newWindow.

I hope that helps a bit.  Windows are always difficult things to get to grips with I find.

Trevor.

0
 

Author Comment

by:sargento
ID: 1278017
FYI opener.top.Right.C.location.href worked. I couldn't use the self name=opener because I was reloading other frames and I was getting the no properties error. It still worked with out naming the frame opener??? It is difficult to explain what I'm doing but it is working now! Thanks
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1278018
I got into the habit of naming the opener with the name 'opener' to try and make referencing work across more browsers.  Most times the opener will be referrable to as opener but on some older browsers the reference opener was not valid and hence you had to actually name it opener. (Hope you managed to follow that!!)

Glad it all worked anyway ;-)

Trevor.

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult 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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now