Change submit button to a loading image with jquery

后端 未结 9 1111
庸人自扰
庸人自扰 2021-02-06 11:12

On a lot of sites lately, I\'ve seen buttons being replaced with loading/thinking images after they are pressed, to prevent double clicks and make sure the user knows something

9条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 11:52

    Any of the above "replacing" strategies will work, but keep one thing in mind: If you aren't posting back (e.g. webforms), but posting to a different page (e.g. MVC), the user will be able to click back. At this point the button will be hidden and all you will see is a spinner.

    I kept running into this problem and found that if you set the unload attribute of the BODY tag to a blank "", this will sort of "default" the page back to its original state. I guess this clears out your browser's cached version of the page so it will know to go back to the original version where the spinner was hidden. After I added this blank unload, it fixed the issue. I've tried it on FF and Chrome so far

提交回复
热议问题