Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • JavaScript: How to Close Browser Window (window.close()) Without Warning

    Posted on April 29th, 2007 mitch Print Print 7 comments

    If you've ever tried to close a browser window from ASP.NET by using the following code:

     

    <input type="button" class="inputfields"
     onclick="javascript:window.close();" value="Close" /></td>

    You will probably receive the following message:

     

    After digging around for 20 minutes or so, I finally found the answer on Anatoly Lubarsky's blog:

     

    <input type="button" class="inputfields"
    onclick="javascript:window.opener='x';window.close();" value="Close" /></td>
    Customization, Development, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    8,374 views
     

    7 responses to “JavaScript: How to Close Browser Window (window.close()) Without Warning”

    1. Hi,

      This doesnt work in IE7 and Firefox 2.0.Any help thanks

    2. Try
      window.opener = self
      window.close()

    3. Still get message asking if you want to close the page.

    4. function OpenMyWin()
      {

      window.opener='X';
      window.open(",'_parent',");
      window.close();
      }

    5. Shahriar Sayed

      Thanks a lot Mani.

      It works nicely in IE7.

    6. Hello!
      Very Interesting post! Thank you for such interesting resource!
      PS: Sorry for my bad english, I'v just started to learn this language ;)
      See you!
      Your, Raiul Baztepo

    7. Cesar Alpendre

      To close a window without warning message, try this:

      Close Window

    Leave a reply