我正在尝试更正在 IE11 兼容性视图中工作但在不兼容时行为不同的 HTML 表单。
用户可以更改表单输入元素中的值,然后单击保存。
Save 按钮抓取整个页面的 innerhtml 并将其存储到隐藏的输入元素中,然后继续提交表单。在 CV 模式下,innerhtml 包含用户所做的编辑。当不在 CV 模式下时,innerhtml 是原始渲染。
如何收集字段中的新值?
<html>
<head>
<script type="text/javascript">
function saveit() {
var markup = document.documentElement.innerHTML;
document.getElementById("html1").setAttribute("value", markup);
document.htmlform.submit();
}
</script>
</head>
<body>
<form name="htmlform" id="htmlform" method="post">
<input type="hidden" name="html1" id="html1"><br>
<input type="text" name="batch_num" id="batch_num" value="100"><br>
<input type="text" name="batch_name" id="batch_name" value="Start"><br>
</form>
<input type="button" name="savebutton" value="Save" onclick="saveit();">
</body>
</html>