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

前端 未结 2 2151
名媛妹妹
名媛妹妹 2021-02-15 09:55

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

2条回答
  •  鱼传尺愫
    2021-02-15 10:30

    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.

提交回复
热议问题