开发者

website offline jsp

I am creating a website using jsp, ajax, servl开发者_JS百科ets.

My framework is prototype.

The connection is bad, so I would like my web application to respond correctly in situations like this.

For example to give a message indicating you are working offline, and to report when plugged in again and can continue.

The solution should work in Internet Explorer 6


You could do a frequent Ajax request to your server, e.g. using jQuery Ajax and a low timeout setting.

The error callback receives the reason for the error in the second argument. If the message is timeout or error, your callback could display a semi-transparent overlay spanning across the whole screen showing the "not available" error message.

Once the Ajax requests succeeds again, you would hide the overlay. In IE7+ and other browsers the CSS for the overlay would be as easy as position: fixed; left: 0; right: 0; top: 0; bottom: 0 but in IE6, it's a bit more difficult - you'd have to look it up.

The overlay is not the perfect solution when the user has started entering some text. If the connection is gone for good, they need access to the text field to copy+paste its contents. You may want to disable the submit button of the current form instead. But that really depends on the context of your application, and will have to be decided by you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜