如何在IE中的后退按钮上单击表单值 [英] How to have form values same on back button click in IE

查看:97
本文介绍了如何在IE中的后退按钮上单击表单值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我点击后退按钮时,如下所示:

 < input type =buttonvalue =BackonClick =history.go(-1); return true;类=后退按钮> 

它不会在IE中显示表单值。



当我提交表单时,我有一个输入表单转到下一页那里我有一个后退按钮,当我点击表单页上,但没有值的形式,我有字段这是问题与IE

解决方案

在页面之间移动时,通常不会保存表格值。如果您的服务器配置支持页面缓存,则可能是这样。不过,另一种方法是将表单值保存到cookie或更新的html 5会话存储中。这可以通过在称为onsubmit的表单头中发射一个函数来完成。

IE

 < form id =[form id]name =[form name]action =[some action]method =[GET or POST]onsubmit =saveFormValues(); > 

在这种情况下,当用户单击提交按钮继续时,这些值将被保存到本地浏览器存储(本质上是一个本地缓存)。



当点击后退按钮时,页面的onload事件可以检查这些值,然后将它们重新分配给适当的字段,从而保留用户之前输入的选项,选择和输入。



设置HTML 5会话存储变量:

  if(typeof(sessionStorage)!==undefined)
{
sessionStorage。[Variable Name] = $([Field Name]) .VAL();
}

回到页面:



$ $ p $ if(typeof(sessionStorage)!==undefined){
{
$([Field Name])。val(sessionStorage。[变量名]);
}

最后一个块将检索保存的状态值。最终提交完成后,请确保您打电话:

  sessionStorage.clear(); 

这会清除会话存储变量,并且会在用户重新访问时使窗体显示为新窗体页面。



希望这有助于。


How to have form values same on back button click in IE?

When I click on back button with following

<input type="button" value="Back" onClick="history.go(-1);return true;" class="back-button">

It does not show form values in IE.

i have a form with some input when i submit form go to next page there i have one back button when click on that i go on form page but there is no values on form which i have field this is issue with IE

解决方案

Form values are not usually saved when moving between pages. They could be if your server configuration supports page caching. An alternative however is to save the form values into cookies or the newer html 5 session storage. This can be accomplished by firing a function in the form header known as onsubmit.

I.E.

<form id="[form id]" name="[form name]" action="[some action]" method="[GET or POST]" onsubmit="saveFormValues();">

In this case when the user clicks the submit button to continue, the values are saved into local browser storage (in essence a local cache).

When the back button is clicked, the onload event of the page could check for the values and then re-assign them to the appropriate fields, thus retaining the choices, selections, and input the user previously entered.

To set a HTML 5 session storage variable:

if(typeof(sessionStorage)!=="undefined")
{
    sessionStorage.[Variable Name]=$([Field Name]).val();
}

On return to the page:

if(typeof(sessionStorage)!=="undefined") {
{
    $([Field Name]).val(sessionStorage.[Variable Name]);
}

This last block will retrieve the saved state value. After final submission is complete, make sure you call:

sessionStorage.clear();

This clears the session storage variables and will make the form appear as a new form when the user revisits the page.

Hope this helps.

这篇关于如何在IE中的后退按钮上单击表单值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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