当用户关闭浏览器时处理未保存的表单数据 [英] Dealing with unsaved form data when user closes the browser

查看:261
本文介绍了当用户关闭浏览器时处理未保存的表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在关闭浏览器或用户更改页面时,我很难找出如何自动保存用户数据的形式。当您要打开对话框时, onBeforeUnload事件可以,但是此时保存更改已为时已晚(除非您只是在onBeforeUnload处理程序中阻止浏览器足够长的时间才能将请求传递到服务器...但是我不想这样做)。

I'm having hard time trying to figure out how to auto-save user data in a form when the browser is being closed or user changes the page. The onBeforeUnload event is OK when you want to open a dialog box, but by then it's too late to save the changes (except if you just block the browser in the onBeforeUnload handler long enough for it to pass the request to the server...but I'd rather not do that).

我确定你们中有些人必须处理未保存的表单问题。你是做什么?您是否:

I am sure some of you have had to deal with the unsaved form problem. What do you do? Do you:


  • 让用户只是丢掉他们的更改

  • 使用模式窗口询问他们是否确定自己做了正确的事,

  • 在更改时迅速保存单个字段

  • 还是您有一些终极方法来自动保存数据,这些数据将不可避免地丢失?

  • let users just lose their changes,
  • ask them using a modal window if they are sure they did the right thing,
  • save individual fields on the fly as they change,
  • or do you have some ultimate method to automagically save the data when it's about to be lost irretrievably?

推荐答案

我喜欢您的第三个选择:

I like your third option:



  • 在更改各个字段时即时保存它们。

I'我必须处理类似的情况,这就是我们正在做的。卖给我的两个主要因素是:

I'm having to deal with a similar situation, and that's what we are doing. The two main things that sell that to me:


  1. 改善的用户体验-$
    的形式给用户留下了深刻的印象, b $ b不会丢失更改。一旦通过验证,它们就是
    承诺的 。
    例如,他输入一个有效的电子邮件
    地址,该地址会立即保存,
    此外,还会为
    的每个字段(为
    成功)提供某种形式的
    反馈已保存(例如,绿色的
    刻度,出现在
    字段旁边)。

  2. 没有其他内容了,<<>哦,我的浏览器当机了
    并且我丢失了所有信息。

  1. Improved user experience - the user will be impressed by a form that does not lose changes. They are 'committed' once they are validated. E.g., he types in a valid email address, and it is saved instantly, furthermore he is provided some sort of feedback for each field that is successfully been saved (a green tick for example, appears next to the field).
  2. No more 'oh crap my browser crashed and I lost all my info' situations.

缺点:开发此类解决方案需要花费额外的工时,并可能最终没有像一个简单的解决方案那样好。也就是说,IMO仍然值得。

Disadvantages: The extra man-hours involved in developing such a solution, and the possibly that it ends up not degrading as nicely as a simpler solution. That said, it is still worth it IMO.

这篇关于当用户关闭浏览器时处理未保存的表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆