简体   繁体   中英

Spinning wheel when performing location.reload();

I am doing some stuff in my Javascript function and then I have to refresh the page using location.reload();

Is there a simple way with jQuery to show a spinning wheel from the point where the page starts to refresh to the point where the page is loaded?

Thanks for your help.

While there might be a solution to just wrap .reload() call info your own function and show spinner before it I seriously doubt the effectiveness. As soon as you issues navigational request, your browser starts killing loaded resources (that also means images) and that's when all GIF's are going to halt with animation. Well maybe not instantaneous but soon enough to spoil the effect...

If you need to avoid doing Ajax, my approach will be the following

  • simply show an animated gif as an image just before calling location.reload();

  • always have the spinner image displayed (first item after your <body> tag, and hide it onload (window.onload / jQuery ready )

there will be some flickering though...

谢谢@Jovan Perovic,您找到了一个解决方案。.load()对我来说非常有用..再次感谢

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM