Javascript navigation in popup with frames

I have to produce a popup-window in one of the frames of a frame-page that controls the whole frameset of the original window. Is that possible?

So if I have
<frameset  rows="125,*">
<frame name="obj_top" src="" marginwidth="0" marginheight="0" scrolling="Auto" frameborder="0">
<frame name="obj_bottom" src="" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">
</frameset>

I would want to open the window from obj_bottom and then target the whole frame.
Is this possible aswell if some link within the frameset uses the _top reference? In other words is there a full-proof way of getting a popup-navigation window that always controls the main window?
It's going to be used in a distributed web-app, so any security-settings or other less elegant solutions may be used!

Thanx in Advanced!
bjbuijzeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
aarieConnect With a Mentor Commented:
This can be done... Let's see if I get things straight here...
The links in the popup navigation window change the contents of your obj_top frame... If a link in the obj_bottom frame has _top as target, the navigation popup still needs to work...


If this is correct, a solution would be:

------------
example code for the popup window:
------------
<html>
<head>
<script language="javascript">
var Unloaded = false;
function FrameSetUnloaded()
{
 Unloaded = true;
}

function ChangeMyLoc(NewLoc)
{
 if ((opener.frames.length > 0) && (!Unloaded))
   opener.obj_top.location.href=NewLoc;
 else
   opener.location.href=NewLoc
} // end ChangeMyLoc
</script>
</head>
<body>
<a href="javascript:" onclick="ChangeMyLoc('test2.html');return true;">change opener main frame</a>
</body>
</html>

----
example code for your frameset:
-----
<html>
<script language="javascript">
function OpenWin()
{
 MyWin = window.open("popup.html","navwin","width=250,height=250");
 return MyWin;
}
</script>
<frameset rows="75%,*">
<frame name="obj_top" src="test.html">
<frame name="obj_bottom" src="test1.html">
</frameset>
</html>

----
example code for your page in the obj_bottom frame:
-----
<html>
<head>
<script language="javascript">
var MyWindow;

function OpenWind()
{
 MyWindow = top.OpenWin();
}

function FrameUnl()
{
 MyWindow.FrameSetUnloaded();
}
</script>
</head>
<body onload="javascript:OpenWind();" onunload="javascript:FrameUnl();">
This is the test page in the bottom frame.
</body>
</html>



Now for the explanation:
Frameset frame:
This page contains the function which opens the popup window. The reason for this is that this is the top window, which contains 0 or more subframes...
If the frameset page would be replaced due to a link with target _top, the popup opener is still open, as this is the top... Therefore, we can still refer to it...


Bottom frame:
When the frame is loaded, the OpenWin() function which is defined in the frameset page is called, which will result in the popup window.


Popup window:
A check is performed to see if the opener window contains frames... If it does, change the obj_top frame location if a link is pressed, else change the top location.... Even if the new _top page contains a frameset, things will go right...

Hope this is clear enough... If not, let me know and I'll try to help you out further...

Arjan.

0
 
bjbuijzeAuthor Commented:
Arjan,

IT seems that we're almost there, but I still get a JS-error within the Obj_bottom file (here bottom.htm)

JavaScript Error: http://127.0.0.1/cfdocs/diversCF/bottom.htm, line 13:

MyWin.FrameSetUnloaded is not a function.

Any last suggestions?

Thnx

0
 
aarieCommented:
Instead of MyWin, it should be MyWindow.... That should take care of the javascript error...
Also make sure all cases are correct, as javascript is case sensitive...
Therefore, MyWindow and mywindow are two different things...


Arjan.
0
 
bjbuijzeAuthor Commented:
Arjan,

Unfortunately that is not enough to do the trick. Something else is still wrong as I keep getting the same JS-error.

Any other possibilities?

Thnx
Bart
0
All Courses

From novice to tech pro — start learning today.