470,591 Members | 1,498 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

Alert box then close window

Hi,

I'm looking for a way to have a message box pop up as a page is
loaded, then, when the user clicks OK on the message box, for the
window to close.

It will be a popup window, so there won't be any "This webpage is
trying to close this window" errors...

Anyone help me out?

Thanks,

Ben
Jul 23 '05 #1
2 22087
BWGames wrote on 03 mei 2004 in comp.lang.javascript:
I'm looking for a way to have a message box pop up as a page is
loaded, then, when the user clicks OK on the message box, for the
window to close.

It will be a popup window, so there won't be any "This webpage is
trying to close this window" errors...


<script type="text/javascript">
alert("Please click OK to close window");
window.close();
</script>

IE6 tested

= or nicer ============

<body onclick="window.close();"
onload="window.resizeTo(300,200);">
Please click this window anywhere to close
</body>

IE6 tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
BWGames wrote:
I'm looking for a way to have a message box pop up as a page is
loaded, then, when the user clicks OK on the message box, for the
window to close.

It will be a popup window, so there won't be any "This webpage is
trying to close this window" errors...


It does not make sense to me to open a window just to get it closed.
FWIW:

if (window.confirm("Close window now?"))
{
window.close();
}

RTFM.
PointedEars
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Simon Fletcher | last post: by
1 post views Thread by Ivan Sutton | last post: by
1 post views Thread by Mark Rigsbee | last post: by
6 posts views Thread by clequieu | last post: by
4 posts views Thread by Ubi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.