Update Progress animated gif stops on postback

社会主义新天地 提交于 2019-12-22 08:46:14

问题


I have used ajax update progress control that shows the animated gif when postback happens.

Problem: It displays for a while but then it stops refershing (or rather, stops playing/revoloving). What could be the actual cause of the same?

Please advice!. Thanks!


回答1:


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? ... :(




回答2:


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'.



来源:https://stackoverflow.com/questions/7185316/update-progress-animated-gif-stops-on-postback

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