我写了一些Javascript来允许编辑HTML表单中的项目列表,包括添加和删除项目.它在Firefox中运行.在Internet Explorer中尝试时,我发现任何添加的项目都没有随表单一起提交.
长话短说......大量简化,调试,找出触发IE忽略新表单输入的行.所以解决了行为问题.
但现在我必须问:为什么?这是IE漏洞吗?
这是简化的代码:
<html>
<head>
<title>Test</title>
<script type="text/javascript">
function add() {
div = document.getElementById("mylist");
// *** Adding text here works perfectly fine. ***
div.innerHTML += " ";
e = document.createElement("input");
e.setAttribute("type", "text");
e.setAttribute("name", "field3");
e.setAttribute("value", "--NEWVALUE--");
div.appendChild(e);
// *** Adding text here works perfectly fine in Firefox, but for
// Internet Explorer it causes field3 to not be submitted. ***
//div.innerHTML += " ";
}
</script>
</head>
<body>
<form action="" method="get">
<div id="mylist">
<input type="text" name="field1" value="value1" /> …Run Code Online (Sandbox Code Playgroud)