日期:2014-05-16 浏览次数:20488 次
<div id="faceContainer" style='position: absolute;height: 150px;width: 300px;left: 27px;top: 100px;display:none;border: 1px solid #999999;'></div> function loadFace() { face = document.getElementById("faceContainer"); var strTable = "<table border= \"1\" cellpadding=\"0\" cellspacing=\"0\">"; var i,j,count; count = 0; for(i=0;i<7;i++) { strTable += "<tr>"; for(j=0;j<14;j++) { if(count <=95) { strTable += "<td><img src='Face/" + count + ".gif' onclick=\"insertFace('"+count+"')\" alt=\"表情"+count+"\"/></td>"; } else { strTable += "<td> </td>"; } count++; } strTable += "</tr>"; } strTable += "</table>"; face.innerHTML = strTable; }
<div id="faceContainer" style='position: absolute;height: 150px;width: 300px;left: 27px;top: 100px;display:none;border: 1px solid #999999;'></div> function loadFace() { face = document.getElementById("faceContainer"); [color=#FF0000]var tbID="myTable";[/color] var strTable = "<table id=\""+myTable+"\" border= \"1\" cellpadding=\"0\" cellspacing=\"0\">"; var i,j,count; count = 0; for(i=0;i<7;i++) { strTable += "<tr>"; for(j=0;j<14;j++) { if(count <=95) { [color=#FF0000]strTable += "<td><img src='Face/" + count + ".gif' onclick=\"insertFace('"+count+"','"+tbID+"')\" alt=\"表情"+count+"\"/></td>";[/color] } else { strTable += "<td> </td>"; } count++; } strTable += "</tr>"; } strTable += "</table>"; face.innerHTML = strTable; }
------解决方案--------------------
<div id="faceContainer" style='position: absolute;height: 150px;width: 300px;left: 27px;top: 100px;display:block;border: 1px solid #999999;'></div> <script> window.onload=function(){loadFace();}; function loadFace() { var face = document.getElementById("faceContainer"); var strTable = "<table border= '1' cellpadding='0' cellspacing='0'>"; var i,j,count; count = 0; for(i=0;i<7;i++) { strTable += "<tr>"; for(j=0;j<14;j++) { if(count <=95) { strTable += "<td><img src='Face/" + count + ".gif' onclick='insertFace("+face.id+")' alt='表情"+count+"'/></td>"; } else { strTable += "<td> </td>"; } count++; } strTable += "</tr>"; } strTable += "</table>"; face.innerHTML = strTable; } function insertFace(face){ alert(face.id); } </script>
------解决方案--------------------