nic*_*oum 6 html javascript internet-explorer
以下脚本Member not found在 IE 中引发错误
try {
var dom = document.createElement("td");
var attribute = document.createAttribute("colspan"); // rowspan has the same behavior
dom.setAttributeNode(attribute);
} catch (err) {
console.log(err.message);
}Run Code Online (Sandbox Code Playgroud)
但以下片段工作正常:
try {
var dom = document.createElement("tr");
var attribute = document.createAttribute("colspan");
dom.setAttributeNode(attribute);
} catch (err) {
console.log(err.message);
}
try {
var dom = document.createElement("td");
var attribute = document.createAttribute("style");
dom.setAttributeNode(attribute);
} catch (err) {
console.log(err.message);
}Run Code Online (Sandbox Code Playgroud)
这是错误还是抛出错误的正当理由。我找不到任何相关的东西。
奇怪的互动:
var attribute = document.createAttribute("colspan");
var dom = document.createElement("td");
attribute.value = "5";
console.log(attribute.value); // "5"
try {
dom.setAttributeNode(attribute);
} // throws error
catch (err) {}
console.log(dom.outerHTML); // "<td></td>"
console.log(attribute.value); // undefined
attribute.value = "5";
console.log(dom.outerHTML); // "<td colspan="5"></td>"
console.log(attribute.value); // "5"Run Code Online (Sandbox Code Playgroud)
注意:我不是在问如何以colspan适用于 IE 的方式设置 a 。我特别想知道上面的问题是否是一个错误。
| 归档时间: |
|
| 查看次数: |
203 次 |
| 最近记录: |