Internet Explorer - 如何使用表单将表单数据从一个本地html页面传递到另一个本地html页面?

时间:2015-01-19 18:33:44

标签: html forms internet-explorer

我在html页面中有一个表单,其操作设置为另一个html页面。在Chrome,FF和Safari中,当我点击第一个html页面的Go按钮时,我将带到包含查询字符串的URL的第二页。

除了IE之外,所有浏览器在我提交表单时都会在URL中显示查询字符串。

在处理本地html文件时,如何让表单提交在IE中显示查询字符串?任何帮助将不胜感激。

HTML表单

<form  method="Get" action="destination.html">
   <input type="hidden" value="test" name="name" />    
   <input type="submit" value="Go"/>
</form>

1 个答案:

答案 0 :(得分:1)

这个答案使用的是jQuery / JavaScript,这可能会或者可能不会对你想要做的事情的简单性有所帮助,但如果你已经在页面上有jQuery,那么尝试这种方法并不是很难:< / p>

在您的HTML <input>中添加ID。

<input type="hidden" id="field" name="field" value="showthis" />

在脚本代码中,试试这个:

    $(document).ready(function() {
    $('#submit-text').click(function () {
        var field = $('#myField').val();
        window.location.replace('destination.html?field=' + field);
    });
});