Sample for Alerting user

S

susie

I need a sample to alert user to save the data entry when
he closes the browser.

When a user close the browser, a message box with
following open pops up:

Do you want to save the data before exit?
Yes No Cancel

Can anyone help? I know I need a client script to generate
the msgbox. However I need a sample.

Thank you very much!
 
K

Kul

Check documentation for OnbeforeUnload and OnUnload event in msdn.

Here is some sample code for you, which clicks a button present in form when
user navigates out of this page.

<HTML>
<HEAD>
<script language="javascript">
function ClickSaveBtn(btnName)
{
var oObject = document.all.item(btnName);
if (oObject != null)
{
oObject.click();
}
}
</script>
</HEAD>
<body text="#000000" onbeforeunload="ClickSaveBtn('saveFormDetails')"
bgColor="#ffffff" leftMargin="0" topMargin="0"
onload="setPageHeadingAndStatus('EDUCATION',2,8)" rightMargin="0">
<form id="MyForm" method="post" runat="server">
.....
...//create a button control here with id = "saveFormDetails"

</form>


regards

-Kul
 

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,191
Latest member
BuyKetoBeez

Latest Threads

Top