PDA

For continued disscussion on this topic : Disabling the 'close' button in new window



nat_k
06-29-2000, 10:09 PM
Does anyone know if its possible to create a popup window that will not allow the user close the window without answering 'yes' or 'no' to a question ?

I need to display an image in this window so a dialog box is not an option...or is it ?

Vincent Puglia
06-30-2000, 12:39 AM
Hi,
You could try something like:

<body.... onUnload="RUsure();">

function RUsure()
{
if (! confirm('Are you sure you want to leave?')
history.go(0);
}

Problem is the unload occasionally fires before the event handler.
Are you afraid people will leave before the image is rendered? If so, you can preload the image in another page (with a *.js file, for example).

Vinny

nat_k
07-02-2000, 05:23 PM
Thanks, but that code is not working.

I'm not afraid of the user closing the window before the image comes up. What I want is that the user cannot close the popup window unless they hit either the yes or no button.

Vincent Puglia
07-03-2000, 03:27 PM
Hi nat,

Try changing it to the following. But, remember as I said earlier -- the close occasionally fires before the unload -- so there is no sure-fire stop in javascript.

<body....onUnload="RUsure()>
function RUsure(URL)
{
if(confirm("Are you sure you want to leave my site now?"))
alert("OK. Hurry back, though.");
else
alert("Phew!!! That was close.");
}

Vinny