YZlat
asked on
How to cancel hta form close
I have the following code activated when the user clicks the close button:
Function FormClose()
intAnswer = _
Msgbox("Do you want to close this form?", vbYesNo, "Form Close")
If intAnswer = vbYes Then
Msgbox "Closing the form..."
Else
Msgbox "Cancelled form close"
End If
How can i cancel form closing if the user clicks "No"
End Function
Function FormClose()
intAnswer = _
Msgbox("Do you want to close this form?", vbYesNo, "Form Close")
If intAnswer = vbYes Then
Msgbox "Closing the form..."
Else
Msgbox "Cancelled form close"
End If
How can i cancel form closing if the user clicks "No"
End Function
ASKER
What is cancelBubble and where is it declared?
ASKER
if you mean window.event.cancelBubble, it does not work, unfortunatelly
Yeah, I've also tried the same with javascript and the message boxes do display but the browser window closes regardless of which button is clicked.
I'll keep looking but I'm at a loss right now.
OM Gang
<script language="javascript">
function promptonclose()
{
if (confirm('Do you want to close this form?')){
alert('you clicked OK');
}else{
alert('Cancelled form close');
window.event.cancel.Bubble = true;
window.event.stopPropogati on();
}
}
</script>
</head>
<body onbeforeunload="promptoncl ose">
I'll keep looking but I'm at a loss right now.
OM Gang
<script language="javascript">
function promptonclose()
{
if (confirm('Do you want to close this form?')){
alert('you clicked OK');
}else{
alert('Cancelled form close');
window.event.cancel.Bubble
window.event.stopPropogati
}
}
</script>
</head>
<body onbeforeunload="promptoncl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure if that posted...took about half an hour ;-)
BTW, the sysmenu="no" removes the max min close buttons from the top right of the window.
Rob.
BTW, the sysmenu="no" removes the max min close buttons from the top right of the window.
Rob.
OM Gang
<script language=vbs>
Sub MyCloseFunction
Dim intAnswer, msg
msg="Do you want to close this form?"
intAnswer=MsgBox(msg, vbYesNo, "Form Close")
If inAnswer=vbYes Then
MsgBox "Closing the form..."
Else
cancelBubble=True
MsgBox "Cancelled form close"
End If
</script>
<body onbeforeunload="MyCloseFun