change cursor to busy while page is loading

后端 未结 3 515
执笔经年
执笔经年 2021-01-02 11:35

I understand how to use javascript to change the cursor to busy while the page is making and ajax call.

However I have a page that does not use ajax, it uses a post

相关标签:
3条回答
  • 2021-01-02 12:17

    Just give each button a class, say "WaitOnClick", then just write it: $(".WaitOnClick").click(function() {

    0 讨论(0)
  • 2021-01-02 12:20

    you can add a handler to the form's submit event.

    CSS

        .wait, .wait * { cursor: wait; }
    

    JavaScript

    function cursorwait(e) {
        document.body.className = 'wait';
    }
    
    var fm = document.getElementById('<% =form1.ClientID %>');
    var proxySubmit = fm.onsubmit;
    
    fm.onsubmit = function () {
        cursorwait();
        if (proxySubmit) {
            proxySubmit.call(fm);
        }
    }
    

    here we're ensuring our method gets called if submit() is called in js like the drop down does when it causes a postback. this should also catch any other instances of the form submitting.

    0 讨论(0)
  • 2021-01-02 12:34

    I am not certain if this is the best or most efficient method but if you want to change the cursor to show the page is busy after the button click the following jQuery should do the trick:

    $(document).ready(function() {
        $(".button").click(function() {
            $("*").css("cursor", "wait");
        });
    });
    
    0 讨论(0)
提交回复
热议问题