By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 2,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

How do you determine the reason for an UNLOAD

P: n/a
When a client requests to leave a Web Page, I want the web page to check for a certain condition. If that condition is met, I want to prompt the user to make sure they want to leave

The method I am currently using is
<HTML><HEAD
..
<script><!-
function PageBeforeUnloadCheck(

..
if (...)AdministratorStatusReportSummaryForm.TheRepor tTypes.value ==
event.returnValue = "The Summary has not been saved!"
--></script></HEAD><body onbeforeunload="PageBeforeUnloadCheck()"
..
</body></HTML

My problem is that the java function PageBeforeUnloadCheck is executed for every PostBack, not just when the page is going to change or the browser closed. After some thought, this makes sense because the client site does not know what the response will be, it might be a new page address. My problem is that I cannot figure out how the java script can know what action the client took. Was it a button press, the change in selection of a dropdownlist, or ...

What variable/parameter/attribute can the script use to determine the user action?
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I think I have figured it out. I found "document.activeElement.id". This seems to give the id of the last button clicked. What I can do is check it. Since closing the window does not update this property, I find I can set it to "" after my check and then when the window is closed the value is "" not the last button's id.
Nov 20 '05 #2

P: n/a
Wrong group.

Try the .aspnet group

Shane

"Michael SL" <mi*****************@compuware.com> wrote in message
news:4B**********************************@microsof t.com...
When a client requests to leave a Web Page, I want the web page to check for a certain condition. If that condition is met, I want to prompt the
user to make sure they want to leave.
The method I am currently using is:
<HTML><HEAD>
...
<script><!--
function PageBeforeUnloadCheck()
{
...
if (...)AdministratorStatusReportSummaryForm.TheRepor tTypes.value == {
event.returnValue = "The Summary has not been saved!";
}
}
--></script></HEAD><body onbeforeunload="PageBeforeUnloadCheck()">
...
</body></HTML>

My problem is that the java function PageBeforeUnloadCheck is executed for every PostBack, not just when the page is going to change or the browser
closed. After some thought, this makes sense because the client site does
not know what the response will be, it might be a new page address. My
problem is that I cannot figure out how the java script can know what action
the client took. Was it a button press, the change in selection of a
dropdownlist, or ....
What variable/parameter/attribute can the script use to determine the user

action?
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.