【发布时间】:2014-01-19 13:23:52
【问题描述】:
我正在尝试将某些数据保存到 cookie 中,这样如果我从一个页面跳转到另一个页面,输入的数据应该被保存并在刷新时重新检索。 我有一个链接:
<div class="esc-policy">
<a href="#">New Link</a>
</div>
在触发点击事件之前,我需要保存输入的以下数据字段:
<table class="form">
<tr>
<td class="label">
<label>Name*</label>
<input id="nameInput" type="text" maxlength="100"/>
</td>
<td class="label">
<label>Description</label>
<input id="descriptionInput" type="text" maxlength="200" >
</td>
</tr>
</table>
我有这样的东西作为我的 js:
if ($.cookie('back_to_url_onPage_referesh')) {
this.name.attr("value", $.cookie('name'));
this.description.attr("value", $.cookie('description'));
}
我不确定这是如何工作的。有人可以帮忙吗!
提前谢谢...
我能够将值保存在 cookie..但是我仍然不知道如何在从一个 URL 跳回到另一个 URL 时检索它。例如:我有一个 url:('#/link/create')我在哪里创建这个 cookie..onclick <a href="#">New Link</a>..我需要导航到另一个 url '#/new-link/create',输入几个表格该页面上的字段,当我点击“保存”按钮时 - <a href="#" class="btn">Save</a>, 它应该带我回到这个网址:('#/link/create')..当我在页面之间导航时,数据当然消失了,如何保存UI 端的数据???
【问题讨论】:
-
查看stackoverflow.com/questions/1458724/….. 这清楚地解释了一切。
标签: javascript jquery html cookies