How to display loading dialog when someone clicks a specific link?

前端 未结 3 871
春和景丽
春和景丽 2021-02-15 09:38

I do have an URL which opens a webpage which is very slow to load and I have no control over it.

I do want to display a loading dialog when someone clicks this URL or to

3条回答
  •  爱一瞬间的悲伤
    2021-02-15 10:39

    You can do this :

    $(function(){
    ​  $('a').click(function(){
         $('
    loading...
    ').prependTo(document.body); });​ });

    Demonstration (change the link to a very slow page for best effect)

    But it depends on the page : if the page sends immediately some content but not the whole content, you won't have the time to see your div.

提交回复
热议问题