Link to home
Start Free TrialLog in
Avatar of sargento
sargento

asked on

loading a url from nested frames popup

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
Avatar of sargento
sargento

ASKER

Edited text of question
Edited text of question
I put up an additional graphic to help clarify at:
www.capoeirasj.com/example/setup2.html
ASKER CERTIFIED SOLUTION
Avatar of Trevor013097
Trevor013097

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.


Trevor I have to digest your answer. I can't use one frameset because different URLs will be loaded in the Right  frame.
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.

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:)
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.

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