How to close current browser window and open a new browser window with single button click?

Posted on 2009-04-16
Last Modified: 2012-06-21
I'm having an Anthem button (in my ASP.NET site) on a web form. On this button click i need to close current browser window (i.e. the form) and at the same point i require to open another browser window (.aspx page) which will be showing a .pdf file.

Question by:23-degrees
    1 Comment
    LVL 3

    Accepted Solution

    You can do like:
    <button onclick="'http:/\/\');window.close();">Open Yahoo and close me</button>

    But this works only in ie and in that also it will ask the user wether he wants to close the window or not.
    This is because of browser security policies
    "Scripts may not close windows that were not opened by script."

    Means If your form itself is a Pop-up window then u can use again and self.close() functions as stated above.
    But If the form is in main parent window then it won't close in FF and in IE it will ask user permission.

    I hope I am clear.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    A Change in PHP Behavior with Session Write Short Circuit ( (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B. provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now