# simple close window



## Toddmaster184 (Apr 22, 2007)

This is probably the dumbest question on here but hey I gotta ask. This simple javascript code that closes the window...

javascript=window.close();

how can I make it so that it does not alert the user. Basically I want to get rid of the javascript alert that says "Are you sure....[OK] [Cancel]" I've searched around online and found a few suggestions but they didnt work.

ie. javascript=window.parent.cloe();

javascript=window.self.close();

any other suggestions or way to do this. The close itself is used with a button.

Thanks


----------



## tomdkat (May 6, 2006)

Here is sample HTML that does what you want:

Main page:

```
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Javascript close window</title>
</head>
<body>
Click <a target="_blank" href="close-win.html">this
link</a> to open a window
</body>
</html>
```
close-win.html:

```
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Close window</title>
</head>
<body>
Click <a onclick="window.close();" href="#">this
link</a> to close this window
</body>
</html>
```
Does that help?

Peace...


----------



## TheRobatron (Oct 25, 2007)

The message asking the user if they want to close the window is usually built into the browser, so I don't think there's any way of disabling it.


----------



## Fyzbo (Feb 6, 2002)

The confirmation is a browser feature to protect the user. For example, my browser is set up to open all pop-ups and new windows in a new tab. If the popup tries to close itself it would close my entire browser, including all the other tabs, so I'm glad it asks as I always cancel.


----------

