JScript添加新行,在HTA文件中无效的处理

发布时间 2023-08-12 18:49:47作者: 小风风的博客

win7 系统中使用appendchild,添加表格行。

要使用兼容模式

<meta http-equiv="x-ua-compatible" content="ie=edge" />

<html>
<head>
<title>第一个HTA的例子</title>
<HTA:ApplicationID="oHTA"
Applicationname="myApp"
border="thin"
borderstyle="normal"

caption="yes"
icon="filename.ico"
maximizebutton="yes"
minimizebutton="yes"
showintaskbar="no"
singleinstance="no"
sysmenu="yes"
version="1.0"
windowstate="normal"
scroll="yes">
<meta http-equiv="x-ua-compatible" content="ie=edge" />
</head>
<script>
function add() {

var tab1 = document.getElementById("tab1");
var row = document.createElement("tr");
var col = document.createElement("td");
var txt = document.createTextNode("aaaa");
col.appendChild(txt);
row.appendChild(col);
tab1.appendChild(row);
}
</script>
<body>
<center>
HTA
HTMLApplication
HTML应用程序
<button onclick="self.close()"style="font-size:18">离开</button>
</center>
<div>
<input type="button" value="add" onclick="add();" />
</div>
<table id="tab1"></table>
</body>
</html>