[英]lose data in the form when clicking the back button on any browser (Django)
My current application has a form which the user fills and hits the submit button to get the output data. 我当前的应用程序具有用户可以填写并点击“提交”按钮以获取输出数据的表单。 But, I loose all the data which was entered into the form when I click the back button on the browser.
但是,当我单击浏览器上的“后退”按钮时,我丢失了输入到表单中的所有数据。 All the drop down select list get reset to initial setting.
所有下拉选择列表都将重置为初始设置。
Is there a way where I can store these inputted values and populate it back when the user hits the back button. 有没有一种方法可以存储这些输入的值,并在用户单击“后退”按钮时将其填充回去。 I want to avoid the user from entering the values into the from again and again..
我想避免用户一次又一次地将值输入到中。
Thanks 谢谢
One way of doing it is to use the Javascript beforeunload event, which occurs when you navigate away from a page, then to store the data in a cookie. 一种方法是使用Javascript beforeunload事件,该事件在您离开页面导航时发生,然后将数据存储在cookie中。 When the user comes back, you could check for the cookie's existance and content, and repopulate the fields with that data.
当用户回来时,您可以检查cookie的存在和内容,然后用该数据重新填充字段。
This is my first reply on StackOverflow, so I hope it was helpful! 这是我对StackOverflow的第一个答复,因此希望对您有所帮助! :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.