简体   繁体   中英

website offline jsp

I am creating a website using jsp, ajax, servlets.

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, eg 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 position: fixed; left: 0; right: 0; top: 0; bottom: 0 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.

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