[英]How do I keep track of when what is the text entered in the form when the user navigates away from the page?
I have a piece of code like this. 我有一段这样的代码。
<form method="get" action="{$self}" name="addcommentform">
<textarea title="{$enterComment}" name="comment" class="commentarea" </textarea>
<input class="Button" type="submit" value="{$postComment}" />
</form>
How do I keep track of when what is the text entered in the form's textarea when the user navigates away from the page? 当用户离开页面时,如何跟踪何时在表单的文本区域中输入什么文本? I want to prompt the user with a warning message so he/she doesn't lose the text.
我想用警告消息提示用户,这样他/她就不会丢失文本。
Thanks. 谢谢。
You could use the javascript/jquery blur event, and if the user hasn't clicked the desired button have it display the form values. 您可以使用javascript / jquery blur事件,如果用户未单击所需的按钮,它将显示表单值。 This might help JQuery Blur Validation Problem
这可能有助于JQuery模糊验证问题
Stu 斯图
Take a look at this Javascript code snippet: 看一下这个Javascript代码片段:
http://www.boutell.com/newfaq/creating/disableclose.html http://www.boutell.com/newfaq/creating/disableclose.html
This takes advantage of the window's onbeforeunload
event which fires when the user is about to leave the page. 这利用了窗口的
onbeforeunload
事件,该事件在用户即将离开页面时触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.