document-wide disable of mousedown

P

PJ6

AJAX is great but I'd like to prevent users from clicking anything again and
causing more actions to happen while the server is working on the current
request without changing the contents of the page. I already set the pointer
to a wait cursor.

What's the best way to disable OnMouseDown document-wide?

Paul
 
E

Evertjan.

PJ6 wrote on 31 jan 2006 in comp.lang.javascript:
AJAX is great but I'd like to prevent users from clicking anything
again and causing more actions to happen while the server is working
on the current request without changing the contents of the page. I
already set the pointer to a wait cursor.

What's the best way to disable OnMouseDown document-wide?

Polyurethane foam?

It is your page, so, fix your clientside script.
 
P

PJ6

Evertjan. said:
Polyurethane foam?

It is your page, so, fix your clientside script.

This is the very reason I hate JavaScript. In order to derive a global
behavior I have to change every last godforsaken element that uses
JavaScript. I acknoweldge that some ways are better than others, but still.

Assuming I have quite a few controls with their own scripts (ASP.NET), I
would have you suggest to me which approach you recommend.

Paul
 
J

jshanman

PJ6 said:
AJAX is great but I'd like to prevent users from clicking anything again and
causing more actions to happen while the server is working on the current
request without changing the contents of the page. I already set the pointer
to a wait cursor.

What's the best way to disable OnMouseDown document-wide?

Paul

Rather then trying to disable mouse actions, try disabling script
actions...

For example, set a Global variable when the request is sent to the
server

xmlhttp=new XMLHttpRequest()
xmlhttp.onreadystatechange=xmlhttpChange
xmlhttp.open("GET",url,true)
xmlhttp.send(null)

Processing = true; //now we know that we are waiting for a response

then in the stateChange function (the current request was completed)...

function xmlhttpChange() {
if (xmlhttp.readyState==4) {
if (xmlhttp.status==200) {
Processing = false;//now we know we've had a successful response
}
}

now before execution of any other function code, wrap a
function OtherPageAction() {
if (!Processing) {

//do other page actions like normal

} else {
UpdateSomeUserMessage("Processing... Please Wait");
}
}

This would obviously need to be tailored to your script, but I hope the
concept helps.
 
E

Evertjan.

PJ6 wrote on 31 jan 2006 in comp.lang.javascript:
This is the very reason I hate JavaScript. In order to derive a global
behavior I have to change every last godforsaken element that uses
JavaScript. I acknoweldge that some ways are better than others, but
still.

Assuming I have quite a few controls with their own scripts (ASP.NET),
I would have you suggest to me which approach you recommend.

No, you would not, because this is a javascript NG and not a .net one.

Javascript cannot be blamed for what other technologies do with it.

Please instead hate .net technology. They have their own NGs.

Furthermore, onmousedown is not Javascript,
in IE vbscript works just as well:

==============
<script type='text/vbscript'></script>
<button onmousedown = "for i=0 to 10:confirm(i):next">
count</button>
==============

Would this vbs do any better?
 
T

Thomas 'PointedEars' Lahn

PJ6 said:
"Evertjan." [...] wrote [...]
Polyurethane foam?

It is your page, so, fix your clientside script.

This is the very reason I hate JavaScript. In order to derive a global
behavior I have to change every last godforsaken element that uses
JavaScript.

This does not have anything to do with the JavaScript programming language,
or any programming language for that matter. It is a Document Object Model
(DOM) issue.

<URL:http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow>


PointedEars
 
R

Richard Kramer

Jasen said:
make synchronous requests instead of async.
It's possible for a synchronous request to hang until the browser times
out - 20 seconds or so. During that time, the browser (FF, MSIE) are
completely unresponsive. I tried to use abort() with a timer but of
course abort() doesn't seem to get called while the request is pending.

So is there a way to limit the timeout or cut short the request? In my
case, if it takes more than about two seconds, something is broken and I
would want to stop the process and alert the user.

Richard
 
T

Thomas 'PointedEars' Lahn

Richard said:
It's possible for a synchronous request to hang until the browser times
out - 20 seconds or so. During that time, the browser (FF, MSIE) are
completely unresponsive.

Which is why asynchronous XMLHTTP requests are implemented.
I tried to use abort() with a timer but of course abort() doesn't
seem to get called while the request is pending.

Of course.
So is there a way to limit the timeout or cut short the request?

Of course, some browsers allows you to configure the timeout. Apart
from that, what you want is not possible with a synchronous XMLHTTP
request. You cannot have your cake and eat it too.

The problem in this discussion is that you want "to prevent users from
clicking anything again" which cannot be done without blocking the UA.
Would it be enough to prevent them from initiating a second XMLHTTP
request while the first one is happening?


PointedEars
 

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

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top