二维数组 ,求解!!!
程序代码:
<html> <head> </head> <body onload="checkall()"> <script language="javascript"> function checkall(){ var calc=open("","_blank"); calc.document.write("<table boder=1 width=400 >"+"<caption>all数组中一共有"+document.all.length+"个元素</caption><tr>"); for(var i=0;i<document.all.length;i++){ calc.document.write("<td>"+document.all[i].tagName+"</td>"); } calc.document.writeln("</tr></table>"); //for(var i=0;i<document.all.length;i++){ var obj=["links","forms","anchors","scripts","images"]; for(j=0;j<obj.length;j++){ calc.document.write("<table boder=1 width=400 sytle='FONT-SIZE:xx-small'>"+"<caption>"); eval('calc.document.write(obj[j]+"数组中一共有"+document.'+obj[j]+'.length)'); calc.document.write("个元素</caption><tr>"); var len=0; eval("len=document."+obj[j]+".length"); alert(len); for(k=0;k<len;k++){ eval('calc.document.write("<td>"+document.'+obj[j]+'[i].name+"</td>")'); } calc.document.writeln("</tr></table>"); } calc.document.close(); } </script> <a href="" name=1></a> <a href="" name="name1"></a> <a href="" name="name2"></a> <img name="img1"/> <img name="img2"> </body> <html>
运行以上代码 报错
问题出在第24行,for循环中,对obj二维数组中的元素 无法定位
求解。。!!