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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    close pop-up using window.close()

    greetings. first post here. thanks in advance for any help.

    I am using the following code in to open a pop-up window (in Flash hence the actionscript tags ..):

    getURL ("javascript:window.open('http://www.mydomain.com/radio/player.php','radio','width=275,height=100');void 0;")

    This is working fine. My problem is how to close this window from other pages on the website.

    I have tried:

    radio.close()

    And it is not working. What would be the correct javascript to use to close the pop-up window that is opened using the code above?

    Thank you,
    calicoder

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,121
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Not sure you can close a window that was opened from Flash, but if you can...

    One not-so-well-advertised fact is that you *can* "find" a window on a page by its name, assuming that your code opened it.

    So you could do:
    Code:
        var radioWin = window.open("","radio");
        if ( radioWin != null ) radioWin.close( );
    Note that you don't pass a URL to the window.open. In this usage, *if* the window of that name already exists, you get a handle to it.

    Caution: If the window of that name does *NOT* exist, this code will open one (blank) very briefly until the close( ) then closes it.

    NOT TESTED IN ALL BROWSERS! Works in MSIE and FF.

    Note: YOU must be the "owner" of the popped up window, of course. That is, your code must be. That's why I worry about invoking this from Flash: Not sure whether the browser sees Flash as same "owner" or not. I'd be curious to know if it works.

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that worked perfectly!!! i was stuck on the name assign from the pages to close the window. thank you so much!

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Always liked that trick, OP.
    Thanks for helping the OP.

    btw is it just me, or is someone playing with the buttons around here?

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,121
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Oh, it's probably me.

    My wife says I'm always leaving the second from the top button of my shirt unbuttoned.

    <grin/>

    Yeah, and the icons have changed color a bit, too.

    Probably installed a new version of the forum code.

    CaliCoder: Thanks for confirming that it works even from Flash.


  •  

    Posting Permissions

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