浏览器兼容性错误

时间:2011-01-19 10:09:02

标签: javascript compatibility

我使用html& amp;创建一个网页(在表格中显示详细信息) JS。哪个适用于Firefox,但不适用于IE。

function frontEnd() 
{
try{
th1 = document.getElementById('th1');
th1.firstChild.nodeValue = "Technology";

th2 = document.getElementById('th2');
th2.firstChild.nodeValue = "Level of knowledge";

t1 = document.getElementById('t1');
t1.firstChild.nodeValue = "HTML";

tl1 = document.getElementById('tl1');
tl1.firstChild.nodeValue = "5";

document.getElementById('MyTab').style.visibility="visible";
}
catch(e)
{
alert(e);
}
    }

th1是表标题的id,t1,tl1是数据id。实际上我试图在用户点击按钮时在表格中显示静态值。它在firefox中成功运行,而不是在IE中。使用IE单击按钮时,它反映出错误“[对象错误]” 请告诉我如何使相同的代码在IE中工作。

谢谢, 纳温

1 个答案:

答案 0 :(得分:2)

为什么不使用 JQuery或Prototype JavaScript库,它们是跨浏览器兼容的。

Jquery

http://api.jquery.com/first-child-selector/

相关问题