Can anyone think of a better way of stopping a user from clicking on anything?
<p>Currenlty when a page is posting back or something else is going on I display a big grey div over the top of the whole page so that the user can't click the same button multiple times. This works fine 99% of the time, the other 1% is on certain mobile devices where the user can scroll/zoom away from the div.</p>

<p>Instead of trying to perfect the CSS so that it works correctly (this will be an on going battle with new devices) I've decided to just stop the user from being able to click anything. Something like <code>$('a').click(function(e){e.preventDefault();});</code> would stop people from clicking anchor tags and navigating to the link but it wouldn't stop an onclick event in the link from firing.</p>

<p>I want to try to avoid changing the page too radically (like removing every onclick attribute) since the page will eventually have to be changed back to its original state. What I would like to do is intercept clicks before the onclick event is executed but I don't think that this is possible. What I do instead is hide the clicked element on mouse down and show it on mouseup of the document, this stops the click event firing but doesn't look very nice. Can anyone think of a better solution? If not then will this work on every device/browser?</p>

<pre><code>var catchClickHandler = function(){
    var $this = $(this);
    $this.attr('data-orig-display', $this.css('display'));
    $this.css({display:'none'});
};
var resetClickedElems = function(){
    $('[data-orig-display]').each(function(){
        $(this).css({display:$(this).attr('data-orig-display')}).removeAttr('data-orig-display');
    });
};

$('#btn').click(function(){
    $('a,input').on('mousedown',catchClickHandler);
    $(document).on('mouseup', resetClickedElems);
    setTimeout(function(){
        $('a,input').off('mousedown',catchClickHandler);
        $(document).off('mouseup', resetClickedElems);
    }, 5000);
});
</code></pre>

<p>JSFiddle: <a href="http://jsfiddle.net/d4wzK/2/" rel="nofollow">http://jsfiddle.net/d4wzK/2/</a></p>
