javascript - js 提交按钮显示 'submit query' ,不起作用,仅在 IE Edge/IE * 中

标签 javascript forms internet-explorer submit microsoft-edge

此表单由 JavaScript 生成。它适用于除 IE Edge 和早期版本的 IE 之外的所有浏览器。我对此进行了研究和调查,但没有找到答案。它在测试的所有其他浏览器中都有效,但在 IE 中,提交按钮值为“提交查询”并且无法提交表单。该 javascript 内嵌在标签下方的页面上。我很困惑。非常感谢任何帮助。

/*generate the form itself */
var loginForm = document.createElement("form");
    loginForm.setAttribute('id',"editDataForm");
    loginForm.setAttribute('method',"post");
    loginForm.setAttribute('action',"submit.cfm");

/*some basic text field */
var someTextBox = document.createElement("input");
    someTextBox.setAttribute('type',"text");
    someTextBox.setAttribute('name',"username");

/*submit button */
var submitThis = document.createElement("input");
    submitThis.setAttribute('value',"Submit");
    submitThis.setAttribute('type',"submit");
    submitThis.setAttribute('name',"SendFormAction");

/*append the textbox to the form */
loginForm.appendChild(someTextBox);

/*append the submit button to the form */
loginForm.appendChild(submitThis);

/*get the div where the form will generate itself */
var loginDiv = document.getElementById("submitFormArea");

/*append the form to the div */
loginDiv.appendChild(loginForm);

最佳答案

根据评论,解决方案是更改此内容:

/*submit button */
var submitThis = document.createElement("input");
    submitThis.setAttribute('value',"Submit");
    submitThis.setAttribute('type',"submit");
    submitThis.setAttribute('name',"SendFormAction");

对此:

/*submit button */
var submitThis = document.createElement("input");
    submitThis.setAttribute('type',"submit"); // <-- Set type before value
    submitThis.setAttribute('value',"Submit");
    submitThis.setAttribute('name',"SendFormAction");

关于javascript - js 提交按钮显示 'submit query' ,不起作用,仅在 IE Edge/IE * 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38619683/

相关文章:

java - Guava 18 无法使用 GWT 2.8Snapshot 和 Java 8 进行编译

twitter-bootstrap - 为什么第二种形式显示在 ot Bootstrap 容器区域之外?

Javascript - I.E.、Chrome、Firefox - 如何包含外部 .js 文件?

css - Internet Explorer 和 css 背景图像不起作用

html - 需要了解 HTML5 样板中的 IE 条件注释

javascript - 使用 JavaScript 检查图像 URL 的可靠方法

javascript - 将变量传递到 AngularJS 应用程序中

javascript - 是否可以在用 javascript 打印之前更改符号?

c++ - Console+Windows的窗体

forms - 中心引导联系表