【问题标题】:Internet Explorer - How to pass form data from one local html page to another local html page using a form?Internet Explorer - 如何使用表单将表单数据从一个本地 html 页面传递到另一个本地 html 页面?
【发布时间】:2015-03-17 20:30:21
【问题描述】:

我在一个 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>

【问题讨论】:

  • 您有method="get" 作为表单的属性之一吗?
  • @rwacarter,感谢您的回复。是的,我确实在我的表格中使用了 get 。是否需要额外的代码?
  • @Porschiey,感谢您的回复。在我的 IE 11 版本上发布和获取都没有显示查询字符串。
  • 啊,抱歉,我没有完全读到你想要一个查询字符串。如果您想这样做,POST 将不正确。我会使用 JavaScript/jQuery 解决方案来做这样的事情,但这是我个人的偏好。你想看看我是怎么做的吗?
  • @Porschiey,感谢您的回复。如果需要 jQuery,你能提供一个提示,我会尝试实现这个提示吗?您是否建议仅将此方法用于 IE 特定情况?

标签: html forms internet-explorer


【解决方案1】:

这个答案使用 jQuery/JavaScript,这对于您尝试做的事情的简单性可能会或可能不会有点多,但是如果您已经在页面上安装了 jQuery,那么尝试这种方法并不难:

在您的 HTML &lt;input&gt; 中,添加一个 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);
    });
});

【讨论】:

    猜你喜欢
    • 2013-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多