...

View Full Version : Switching between 'frameset' and 'popup' with JavaScript



boptix
04-11-2005, 07:33 PM
I have two simple HTML-documents: 'page_a.htm' and 'page_b.htm'. Both documents must be open at the same time, which can be achieved in two different ways:
- 'frameset mode': 'page_a.htm' and 'page_b.htm' are loaded into seperate frames in a frameset
- 'popup mode': 'page_b.htm' is loaded into a popup window, 'page_a.htm' into the main window
The user must be able to switch between 'frameset mode' and 'popup mode' by clicking on the 'Change mode' link in 'page_b.htm'.

Switching from 'frameset mode' to 'popup mode' works fine (please try it on the demo page: http://boptix.50webs.com/frameset.htm). However, when you want to switch back to 'frameset mode' a problem occurs: the main window (with 'page_a.htm' in it) can't be accessed, because the 'opener' frame does not exist anymore (the 'frameset.htm' was replaced by 'page_a.htm' when switching to 'popup mode').
I tried to set the name of the main window by adding an 'onload' attribute:

<body onload="window.name='blah';">

This works partially: the window name is set, but it seems that the new window name can only be used in the 'target'-attribute of <a>-tags and NOT in JavaScript.

Does anyone have an idea how to solve this? How can I get a handle to the main window so I can switch back to 'frameset mode'?

WMJB
04-12-2005, 12:50 AM
Try this...

After opening page_b.html in the popup window, get a handle back to the parent with OPENER. THen change the source files of the parent window using the opener reference. Hopefuly you should still have the reference there.

Your other option is to not replace the frameset with page_a.html... Keep the frameset document loaded at all times. So, load the popup with page_b.html, then call a function in the main page that repositions the frames so that only page_a.html is visible. Then you will never lose contact with your parent!

Hope that helps.

WMJB

glenngv
04-12-2005, 05:49 AM
This works partially: the window name is set, but it seems that the new window name can only be used in the 'target'-attribute of <a>-tags and NOT in JavaScript.

You can.

window.open("frameset.htm", "page_a");

boptix
04-12-2005, 07:21 PM
Thanks for all input! I finally came to the following solution (please have a look at the soure code of 'page_a.htm' and 'page_b.htm'):
http://boptix.50webs.com/solution/frameset.htm

WMJB
04-13-2005, 12:51 AM
Thats pretty cool. I never would've thought to use a form submit in that siutation. It works really well!

glenngv
04-13-2005, 03:42 AM
Thanks for all input! I finally came to the following solution (please have a look at the soure code of 'page_a.htm' and 'page_b.htm'):
http://boptix.50webs.com/solution/frameset.htm
My solution is simpler, why didn't you use it?

boptix
04-13-2005, 07:46 PM
Hi glenngv, I did another test and you are totally right! That option works pretty good aswell and is even simpler. I created a test page: http://boptix.50webs.com/solution2/frameset.htm
Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum