Update Progress animated gif stops on postback

吃可爱长大的小学妹 提交于 2019-12-05 14:38:41
Jourdan

The animation of a .gif will stop on PostBack with Internet Explorer. The problem is inherent to Internet Explorer. Apparently this issue goes all the way back to IE 6 (though I've only confirmed it in IE8).

There is a little hack around it, and that's by updating it's source with a setTimeout

function UpdateImg(ctrl) {
var img = document.getElementById(ctrl);
img.src = img.src;
}

setTimeout(function() { UpdateImg('image1'); }, 50);

You could also use jQuery to animate a graphic. This works in IE, but now I notice that Chrome doesn't work all the way through the animations on PostBack. There's always something isn't there? ... :(

Some Browsers pause rendering of the current displayed elements while they are processing JavaScript. So the behaviour I always notice is this:

  • The Page starts a postback and displays the progress animation
  • The server processes the request while the animation is running
  • The server sends the results back to the browser
  • The browser receives the result and starts processing it, while PAUSING the animation
  • When the browser is finished it removes the progress animation

Depending on how long the browser takes to compute the actual changes on the page (longer on older browsers, especially IE6, IE7 are extremely slow) this can take quite some time. Additionally, errors in the JavaScript at this stage could also cause the progress panel to be displayed 'forever'.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!