Sehboo wrote:
Quote:
In my application, there are lot of processes which take several
seconds. What we want is that once user clicks on a button (or link or
whatever) and while we are processing that request, we don't want user
to do anything else on the page. We want to disable everything. I
have following javascript on all of my pages (which is supposed to
work), but it doesn't work.
>
<script language="JavaScript">
function ignoreinput() {
return false;
}
>
function stop_input() {
window.attachEvent("onkeydown", ignoreinput);
window.attachEvent("onclick", ignoreinput);
}
</script>
>
<form name="_ctl0" method="post" action="mypage.aspx"
language="javascript" onsubmit="return stop_input(this);" id="_ctl0"
runat="server">
The problem, as I see it, is that when the form is submitted you stop
the input but the page is already reset because it's navigating to
mypage.aspx which means your event handlers are reset. The program flow
is going...
->Submit...
->Attach events....
->Browser navigates to mypage.aspx as it submits the data.
->The page is destroyed as the browser navigates to mypage.aspx
->The event handlers are destroyed when the page is destroyed.
So what you need to do is to have stop_input return false, this will
keep the submit from actually happening and the navigation event from
happening. Then use a small ajax call to submit the data. (You can
see an example of an ajax post call here:
http://www.hunlock.com/blogs/AJAX_POST-It_Notes -- fair warning, I wrote
the tutorial, it's my site ).
That will give you more control over what's going on while your data is
being processed. It will allow the data to be submitted while leaving
the page intact, which means the event handlers are going to be able to
work.
None of this will help you if the user starts messing with his browser's
forward/back buttons. You have a great deal of control over what the
user can do in the browser window but once the mouse leaves the content
area and hits the browser controls you're pretty much stuck which is
ironic because its designed that way to make sure the user can get
unstuck ;)
Hope that helps you out a bit.
--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA