Alert box then close window

B

BWGames

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
 
E

Evertjan.

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
 
T

Thomas 'PointedEars' Lahn

BWGames said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top