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…

更多相关文章

  1. JavaScript中,提取子字符串方法:Slice、Substring、Substr的比较
  2. java 如何获取动态网页内容,返回字符串
  3. NodeJS - 解析JSON(只有字符串或数字)
  4. 如何在JavaScript中对字符串排序
  5. JSON.parse(xhr.responseText)意外的字符串错误
  6. 如何在url中将特殊字符作为查询字符串传递
  7. JS计算任意字符串宽度
  8. 如何在JavaScript中按大写和小写分割字符串?
  9. 使用jackson json将属性添加到json字符串

随机推荐

  1. C#中五种访问修饰符作用范围实例详解
  2. 关于json result的实例代码
  3. H5结合百度map实现GPS定位的实例教程
  4. 总结.NET平台上一些常用的框架
  5. C#中foreach实例代码
  6. MailKit帮助类实例详解
  7. 泛型的概述和具体使用
  8. 分享一个磁盘文件查看系统
  9. 什么是MVVM架构和数据绑定?
  10. 实现内容精准化搜索和用户精准化推送的实