保留表单数据的策略(在选项卡/浏览器关闭时) [英] Strategies for preserving form data ( on tab/browser close )

查看:170
本文介绍了保留表单数据的策略(在选项卡/浏览器关闭时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在任务管理应用程序中遇到问题,用户偶尔关闭他们的浏览器/选项卡,并且键入的信息消失了,因为他们不小心关闭了浏览器/选项卡,导致输入的文本丢失(有的可能花半小时输入文字).

I have an issue with a task management application where occasionally users close their browsers/tabs and the information which they type goes away because they accidentally close a browser/tab, resulting in the loss of the text which they've entered ( and some can spend half an hour entering in text ).

因此,我必须提供一个解决方案,我有两个想法,但希望获得最好的输入,或者如果您有更好的解决方案,请告诉我.

So I have to provide a solution, I have a couple ideas but wanted input on the best to go with, or if you have a better solution let me hear ya.

选项1:

  • window.onunload或可能的window.onbeforeunload事件上,调用confirm()对话框,然后首先测试任务记录区域中是否有任何文本且不为空白.如果不是空白,请调用window.confirm()并询问用户是否要在不保存日志的情况下关闭选项卡/窗口.
  • On the window.onunload or possibly window.onbeforeunload event invoke a confirm() dialog and first test whether the task logging area has any text in it and is not blank. If it's not blank, invoke window.confirm() and ask whether the user wants to close the tab/window without saving a log.

我对选项1的担心是它可能会干扰用户.

My concern with option #1 is that it may be user intrusive.

选项2:

  • 在同一事件上,请勿调用任何Confirm(),而应将文本强制保存在cookie的任务记录区域中.然后可能提供一个按钮,尝试从同一页面上的cookie还原任何保存的任务信息,因此单击该按钮将使其解析cookie并检索信息.

推荐答案

如果用户很笨拙,无法提交自己一直在做的事情,那么他们就不必介意询问他们是否打算做某事显然是愚蠢的.

If the user is daft enough to navigate away before submitting what they have been doing, then they shouldn't mind an intrusion to ask if they mean to do something that is apparently stupid.

此外,SO在导航时使用确认对话框,并且 处的大多数(某些)用户都很聪明.

Also, SO uses a confirmation dialog on navigating away, and most (some) users here are pretty smart.

这是最容易使用的方法,可能会为用户提供更多帮助.

This is the easiest to use, and will probably help the users more.

如果某人写了很长的一段文字,然后关闭浏览器而不提交它,那么他们可能会更乐于在那里整理问题,而不是第二天早上才发现自己没有这样做……

If someone writes a long piece of text, then closes the browser without submitting it, they might be more pleased to sort the problem there and then rather than finding out the next morning they didn't do it...

这篇关于保留表单数据的策略(在选项卡/浏览器关闭时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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