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
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lahore, Pakistan
    Posts
    150
    Thanks
    2
    Thanked 0 Times in 0 Posts

    close the current window when opening a new popup

    How can I close the current window when opening a new popup window through onload method

    Means i open a popup in full screen when a page loads, and i want that the original window which opens the popup will close automatically without any notice.

    Plz Help

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    via javascript, moving you there...
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can simply use the window.close(); function to close the current window.

    You have the popup in the onLoad, correct? Just add this to the function you are using to load the new popup:

    Code:
    window.close();
    Is that what you wanted?

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You can't close the parent window. IE will give you a confirmation saying a script is trying to close the window do you want to allow it etc. Firefox and other browsers simply won't allow it. You can only close the parent window if that window was opened with javascript.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You are only allowed to close windows that you opened. If you open a new window then you can close it by calling the close method for that window. If you didb't open the window then you can't close it. Most browsers will either ignore the request or will ask if the person wants to allow you to close the window - many people will then reply NO since they are using that window to browse the web and intend to continue browsing after leaving your site.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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