无法获取属性'innerHTML'的值:object为null或undefined

时间:2012-10-30 17:29:22

标签: javascript html

我使用flowplayer来显示视频。它适用于firefox和chrome。但它在iexplorer中不起作用。错误给我的是:

SCRIPT5007:无法获取属性“innerHTML”的值:对于document.getElementById(src_row).innerHTML,对象为null或未定义。 “src_row”有值,但innerHTML没有值。

该功能如下。请帮助如何使用ie。感谢

function copyRows(dest_row, src_row_id){
    var src_row = 'row' + src_row_id.toString(); 
    document.getElementById(dest_row).innerHTML = document.getElementById(src_row).innerHTML;
}

2 个答案:

答案 0 :(得分:0)

您在src_row来电中提及getElementById,但在调用之前您似乎正在修改ID

var src_row = 'row' + src_row_id.toString(); 
document.getElementById(src_row)

假设这样的电话:

copyRows( myRow, 'rowID' );

getElementById(src_row)会查找ID rowrowID的元素。

这是你的意图吗?将'row'附加到ID的begninning?

答案 1 :(得分:-1)

function copyRows(dest_row, src_row_id){
    var src_row = 'row' + src_row_id.toString(); 
    console.log(src_row);
    document.getElementById(dest_row).innerHTML = document.getElementById(src_row).innerHTML;
}

看看是否能为您提供所需的字符串。