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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    139
    Thanks
    8
    Thanked 0 Times in 0 Posts

    close a popup on site exit

    I have a popup that plays a full song. I have it in a popup so you can listen to it and browse the site at the same time, rather than losing it as soon as you leave the page.
    However, as a person who hates popups and finds that, after a while of surfing different sites, they tend to accumulate if you don't see them, I would like to have this one close when the person leaves the site.
    I have external links in my site, but they all open to "target=_blank". Internal links remain in the same parent window.
    Is there a way to tell the popup that the parent window is leaving the domain (yes, I have a real domain name - that must make it easier?) and to shut down, without making the user do it?
    Thanks.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    My opinion is that it is improper to say "parent" when talking about popups. I think that, when open, a popup becomes an independent window so you can not close an independent window from another independent window (otherwise the rival companies would include a script to close one eachother's pages if user open both ... LOL )

    I see some other solutions for your problem:

    1. If you have a parent frame all over your site:

    - build another frame, 1X1 px dimension, with your music in
    - build an invisible DIV on parent frame, with.....

    2. If you have not a parent frame:

    - build a parent frame, this time your parent frame will be that 1X1 px dimension, with music
    - make your popup open beneath your page (there are some scripts help u do so) then build 2 other scripts, one to focus to the popup when main page is unloaded

    onunload="javascript:focus('popup.html')" or smth like that

    , the second script on the popup, who will close the popup when it is focused

    window.onfocus = window.close(); or smth like that

    The latest ideea... I am not sure it will work, because I am affraid that the popup will be focused anyway, even for a second when open, so it will close itself right away...:-))

    Has anyone other ideeas?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    You can have a timer running in your popup window that loops and checks every few seconds to see if the parent windows still exists.

    This idea will add a lot of administrative work. Have a function execute onunload that either checks to see what domain you are navigating to or have an onclick event for every link that tells you whether the link is navigating away from your site or not.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    is it possible, arnyinc? How could a function client-side written in a page to check if another independent page is open or not?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    A parent can refer to a popup that it spawned and vice versa. There is a bug in IE with window.opener that will cause problems though.

    -----------------

    Here is a link to something that might work, but it is untested.

    http://developer.irt.org/script/98.htm

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    sounds logical... but... it might be a silly question, yet ...where do I specify the child window's name? Where to insert name="" ?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Originally posted by Kor
    sounds logical... but... it might be a silly question, yet ...where do I specify the child window's name? Where to insert name="" ?
    Create the popup like this:

    var popwin = window.open('your_page.htm', 'mywin', any other variables);

    I don't recall if you would refer to it as mywin or popwin in this situation, but I believe mywin is correct.

    You can then refer back to the parent/opening window as window.opener.

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Sorry for insist... yet I don't see...

    var popwin = window.open('your_page.htm', 'mywin', any other variables);

    that means I am looking for a window called "mywin" by the name. Ok till now. But were do I write in the inner popup something like name="mywin", to be alble to refere that popup, an not another... This is my quest...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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