Click to See Complete Forum and Search --> : Automatically close window


TonyV
07-28-2003, 04:12 PM
I am trying to automatically close a window after an activex returns. It seems like the best way to do it would be to use the onload event like onload="window.close();return false;". Note: i do not want to use the onclick event because I want this to be automatic. Does anybody know how to do it? Thanks.

pyro
07-28-2003, 04:26 PM
That should work fine... is it not?

TonyV
07-28-2003, 05:29 PM
If this works, I must be doing it wrong. The window just sits there for me. Have your tried this?

pyro
07-28-2003, 05:33 PM
Works fine for me:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Close Window</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body onload="window.close();">
</body>
</html>

TonyV
07-28-2003, 08:06 PM
Perhaps there is no way to close this except answering Yes when asked "Do you want to close". I was able to do this, but I thought I could do better. Is this your understanding?

pyro
07-28-2003, 09:08 PM
There is a way around it, but please be careful how you use it. It has potential to greatly annoy your users.

http://www.infinitypages.com/research/selfclose.htm

TonyV
07-29-2003, 12:05 AM
The example worked fine, but it was an onclick event. Trying to change it to an onload event, I came up with the following which didn't work:

<html>
<head>

<script language="javascript" type="text/javascript">
function closewin()
{
self.close();
}
</script>
</head>

<body onLoad="opener=self;">

<onload="closewin();">

</body>
</html>

I'm obviously missing something.