JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript
photo of Stephen Chapman

Stephen's JavaScript Blog

By Stephen Chapman, About.com Guide to JavaScript since 2004

Can JavaScript Close This Window?

Tuesday August 26, 2008
JavaScript can tell whether the current page is in a window opened by JavaScript

JavaScript can only close windows (and tabs) that were opened by JavaScript. If the window or tab was already open before your visitor got to your site then there is nothing you can do to close it - if you try then IE will pop up an alert telling your visitor that you are trying to close their browser while other browsers will just completely ignore the request. You can get more consistent treatment between browsers if you test for yourself whether the close is allowed before attempting it - that way you don't annoy your IE visitors with that alert.

Can JavaScript Close This Window?

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore JavaScript

About.com Special Features

JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.