Laxminarayana Boojewar

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromLaxminarayana Boojewar
ToMe
SubjectHow to active and decativate mouse click in JAVASCRIPT dynamically
Date23 February 2005 05:52
Dear sirs,
 I need ur help in the following issue.  I hope that I'll get it from you.
When Processing going on page I need to disable(dont allow click)all the
links and I need to show Hour Glass.  After completion of the process I
need to activate (allow Click).  In the Page there three IFRAMES  in that I
am loading three diffrent files .  In the middle iframe I doing some
process, at that time I need to get Hour Glass throught the page.  Please
help me this, as early as possible.

Thanks n Regards
Laxminarayana Boojewar
FromMe
ToLaxminarayana Boojewar
SubjectRe: How to active and decativate mouse click in JAVASCRIPT dynamically
Date23 February 2005 9:32
Since you will need to apply the link disabling to all of the links on the
page, I suggest you attach an onclick event handler to all of the links.
The event handler should return false if you are processing and the links
are clicked. Otherwise it should return true.

As for the cursor, setting it on the body tag will set it for everything
except form elements and links. These must be done separately:

Put this just before the </body> tag:

<script type="text/javascript"><!--

//link disabling
var amProcessing = false;
for( var x = 0, y = document.links; y[x]; x++ ) {
 if( y[x].onclick ) { y.oldonclick = y.onclick; }
 y[x].onclick = function {
   if( amProcessing ) { return false; }
   if( this.oldonclick ) {
     var tst = this.oldonclick();
     if( typeof( tst ) == 'boolean' ) { return tst; }
   }
   return true;
 };
}

//cursor changes
function setCursor(oType) {
 if( !document.body || !document.body.style ) { return; }
 document.body.style.cursor = oType;
 for( var i = 0, a = document.links; a[i]; i++ ) {
   a[i].style.cursor = oType;
 }
 for( var i = 0, f = document.forms; f[i]; i++ ) {
   for( var j = 0; f[i].elements[j]; j++ ) {
     f[i].elements[j].style.cursor = oType;
 }
 }
}

//--></script>

Now, whenever you are processing:
amProcessing = true;
setCursor('wait');
and when you are finished processing:
amProcessing = false;
setCursor('');


Hope this is what you needed


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.