开发者

GWT: progess of image load

is there any way, with GWT, to get progress callbacks for a loading image? we have an app that loads images over a potentially very slow connection and we'd l开发者_如何学Pythonike the user to be able to tell if things are progressing, or just failed completely.

i don't see anything that would leave me to believe this is possible, so just checking myself here.


GWT compiles down to Javascript. So ultimately GWT can do what Javascript can do.

About your problem: it is doable via XHR, but apparently it does not work in IE: AJAX Page Download progress

The GWT part: you can take any of the Javascript solutions mentioned in the links and wrap it in JSNI.

Update:

XHR and Images dont play nicely together. Here are the workarounds:

  1. Set proper HTTP expire header on the image so that it gets cached. Load it via XHR. Then load it again via image tag. The second request should be handled by the browser cache.
  2. Serve image on your server as Base64-encoded image then wrap it: <img src="data:image/gif;base64,[insert data here]"/>
  3. Various hacks with xhr.overrideMimeType(). You can find them around the net. They behave differently from browser to browser.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜