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

前端 未结 2 2150
名媛妹妹
名媛妹妹 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:19

    If you also need an animation, it becomes a complicated matter as browsers behave very differently. Some stop all GIF animations when a new page starts loading. Basically it comes down to something like this if you have jQuery and download the spin.js library.

    See working solution here:

    http://jsfiddle.net/7aJyP/

    
    
    
    
    
    link

    If you use an animated (GIF) the animation may freeze on some browsers. I used spin.js library ( http://fgnass.github.com/spin.js/ ). While GIFs get frozen the javascript animation seems to be working.

    Please test with ALL browsers!

提交回复
热议问题