Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Switching between 'frameset' and 'popup' with JavaScript

    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'?

  • #2
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    "It doesn't matter if I'm optomistic or not, nothing ever works out for me."

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by boptix
    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");
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats pretty cool. I never would've thought to use a form submit in that siutation. It works really well!
    "It doesn't matter if I'm optomistic or not, nothing ever works out for me."

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by boptix
    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?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •