[英]Simple Javascript does not work on Interner Explorer
我的网站有安全的登录表格。 在登录过程中,我使用一个名为form.js
的文件。 输入用户名和密码后,它将加载但不会将我定向到该页面,但是在Chrome上一切正常。 我收到此通知(单击图像的链接):
这是forms.js代码:
function formhash(form, password) {
// Create a new element input, this will be our hashed password field.
var p = document.createElement("input");
// Add the new element to our form.
form.appendChild(p);
p.name = "p";
p.type = "hidden";
p.value = hex_sha512(password.value);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
form.submit();
}
关于这个问题有什么想法吗?
将元素添加到DOM后,Internet Explorer不允许您更改它的type
属性。 在追加节点之前,必须设置此属性。
另外,设置节点属性的正确方法是使用setAttribute()
函数。
这应该工作:
function formhash(form, password) {
// Create a new element input, this will be our hashed password field.
var p = document.createElement("input");
p.setAttribute("name","p");
p.setAttribute("type","hidden");
p.setAttribute("value",hex_sha512(password.value));
// Add the new element to our form.
form.appendChild(p);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
form.submit();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.