未捕获的IndexSizeError:未能在'HTMLTableRowElement'上执行'insertCell':提供的值(1)不在范围内[- 1,0]
16lz
2021-01-22
Why pictures don't appear on my page? Uncaught IndexSizeError: Failed to execute 'insertCell' on 'HTMLTableRowElement': The value provided (1) is outside the range [-1, 0] - this error call on this string.
为什么我的页面上没有图片?未捕获的IndexSizeError:未能在'HTMLTableRowElement'上执行'insertCell':提供的值(1)在范围之外[- 1,0]——这个字符串上的错误调用。
[JS]var cell = row.insertCell(i);[/JS]
function createPreview() {
var f = document.createElement("table");
var row = f.insertRow();
var cell = row.insertCell(i);
for(var j = 0; j < count ; j++) {
var img = new Image();
img.src = "image/" + j + ".jpg";
img.id = "i" + j;
cell.appendChild(img);
}
document.body.appendChild(f);
}
</script>[/JS]
2 个解决方案
#1
3
This is old, but for anyone reaching here, and having the same problem, the first cell you have to put in a row is the cell 0, then, you can put the cell 1, for example: You cant put the cell 0, and after that the cell 2, because you need a cell 1.
到达这里,这是旧的,但任何人都有同样的问题,第一个单元格你必须把连续细胞0,然后,你可以把细胞1,例如:你不能把细胞0,细胞2之后,因为你需要一个细胞1。
The way to do it is insert cell 0,1,2,3...
方法是插入单元格0 1 2 3…
更多相关文章
- JavaScript中,提取子字符串方法:Slice、Substring、Substr的比较
- java 如何获取动态网页内容,返回字符串
- NodeJS - 解析JSON(只有字符串或数字)
- 如何在JavaScript中对字符串排序
- JSON.parse(xhr.responseText)意外的字符串错误
- 如何在url中将特殊字符作为查询字符串传递
- JS计算任意字符串宽度
- 如何在JavaScript中按大写和小写分割字符串?
- 使用jackson json将属性添加到json字符串