Mayero

I want to prevent the user from accidentally exiting an HTA. When any
attempt to close the application is made (such as clicking on the close
button), a dialog should appear asking the user to confirm the exit. If the user clicks OK, the application closes; if the user clicks Cancel, the application remains open.

I wanted to do this using the onbeforeunload event, and wrote the following HTA as a test. But the app always closes whether the user clicks OK or Cancel.

When I rename the file from Test.hta to Test.htm and run it in IE (and
allowing blocked content), the file operates as intended and allows the user to cancel the exit.

Can anyone explain why this method works for *.htm and not for *.hta And can anyone suggest a way of accomplishing this in an HTA

Thanks.
David

The code:

-------------------------------------------------------------
<html>
<title>Click the close button</title><head>
<hta:application
id=""
applicationname="" version="1.0"
icon="" windowstate="normal" navigable="yes"
singleinstance="no" showintaskbar="yes"
sysmenu="yes" caption="yes"
border="thick" borderstyle="complex" innerborder="yes"
maximizebutton="yes" minimizebutton="yes"
scroll="no" contextMenu="yes"
</hta:application>

<script href="" type="text/javascript">

window.onbeforeunload=askQuit;

function askQuit(){
return("Really quit ");
}

</script>
</head>

<body>
</body>

</html>
-------------------------------------------------------------



Re: Internet Explorer Web Development HTA won't respond as expected to onbeforeunload event

TSChong

Hi,

I was just wondering if have any fix for this issue has been found

Thanks.

TS





Re: Internet Explorer Web Development HTA won't respond as expected to onbeforeunload event

TSChong

I've been searching for possible fix or workaround on the issue for quite a while.

Any idea or suggestion is very much appreciated.





Re: Internet Explorer Web Development HTA won't respond as expected to onbeforeunload event

thetd

This always worked with my HTA application before IE7. With IE7, I get mixed behavior. 2 out of 3 machines I have with IE7 exit regardless of which button is pressed, while one behaves appropriately. On one of those 2 that doesn't work correctly, it worked correctly with IE6, then began working incorrectly when I upgraded to IE7.

Any solutions to this would be greatly appreciated.