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

Internet Explorer - How to pass form data from one local html page to another local html page using a form?

我在一个 html 页面中有一个表单,该表单的操作设置为另一个 html 页面。在 Chrome、FF 和 Safari 中,当我单击第一个 html 页面的“转到”按钮时,我将转到第二个页面,其中 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>

这个答案使用了 jQuery/JavaScript,对于您尝试做的事情的简单性而言,这可能会或可能不会太多,但如果您的页面上已经有 jQuery,则不会尝试这种方法太难了:

在您的 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);
    });
});