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 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    reload parent on pop-up unload

    i have been trying to find a way to make JS to something (explained below) but it doesnt work. does anyone have any suggestions?

    the parent window opens a pop-up via JS. parent window may optionally have its name set to "main" (window.name = "main"). when the user closes the pop-up (like by clicking the "X" on the titlebar in Windows) the pop-up executes code to refresh the parent window.

    any help would be nice, thanks in advance

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In body tag of your popup window, try this: (untested)
    Code:
    <body onUnLoad="window.opener.location.reload(1);">
    But I'm pretty sure that will work.. let me know.

    Sadiq.

  • #3
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is unreliable in IE. Its a special feature that MS added(also known as a flaw).

    I'd recommend instead adding an onFocus event handler right before the pop-up is created. Then when ever they focus back on the generating page, it can use that onFocus to check if the pop-up elemnt is there.

    I'll code it up for you in a second.

  • #4
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oo...thanks a lot and thats for the code you are doing
    btw...do u know why IE show the directory of the file (pop-up) in the pop up when i have this:

    function reloadMainPage ()
    {
    window.opener.location.reload(false);
    }

    somewhere in the head and this for a link in the pop-up:

    <a href="" onclick="javascript:reloadMainPage();">Click here to reload main
    page</a>

  • #5
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry this took a bit, had some work stuff to attend to, heh.

    Code:
    <script>
    function focuser()
    {
    window.open('filetoopen.extnsion','windowname','params');
    window.onfocus = checklive;
    }
    function checklive ()
    {
    window.location.reload();
    }
    </script>
    <a href="#" onClick="focuser()">Link for pop-up</a>
    Last edited by SlySecretSpy; 07-15-2004 at 02:01 AM.

  • #6
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    um...i am sorta lost how it works
    well from "window.onfocus = checklive;" down


    is it possible to
    1. generate a pop-up
    2. when the pop-up is out of focus, make the parent check if the pop-up still exists and have a conditional
    if (pop-up is closed)
    then refresh yourself (parent)
    end if


    sorry, i still trying to explain things in a sorft of VBish way
    Last edited by conspiracyx; 07-15-2004 at 02:11 AM. Reason: added more content

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Didn't sad69's suggestion work?

    <body onUnLoad="window.opener.location.reload(1);">

    It can be modified a bit to ensure that the opener is still open before reloading it.

    <body onunload="if (opener && !opener.closed) opener.location.reload(1);">

    Or you can't use it because the popup navigates to other pages too?
    Glenn
    ____________________________________

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

  • #8
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    onUnload doesn't seem to respond correct in IE

    If you do a google search you will find multiple people backing this up, or you can try it yourself

  • #9
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    aight i will look aroung with Google. i still think the average user will probably click a link to close the pop-up using the link rather than the ( X ) and its a minor inconvenience with this IE 'feature' anyways

    <3 firefox

  • #10
    New Coder
    Join Date
    Nov 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My method seems to work. It reloads when ever you regain focus on your main page.

  • #11
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Refreshing parent window when Pop-Up closes.

    I too, was having this same problem. The solution provided by SAd69 does indeed work. It even works for a window that's part of a frameset.

    Thanks SAd69 for the help.

    CodeCrazy


  •  

    Posting Permissions

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