图片改成绝对路径试试,我这边用绝对路径测试可以正常显示,能显示之后再调试相对路径

解决方案 »

  1.   

    可以显示,不过调试时有点错误,比较一下吧:
    <p id=mp></p>
    <script type="text/javascript">
    var text = '987',text1='page.987',text2='http://www.csdn.net/Images/logo_csdn.gif';

    var cell =document.createElement("td");
                cell.setAttribute("style","cursor:pointer" );
                cell.setAttribute("height","250px" );
                cell.setAttribute("valign","top" );
                var t=document.createElement("table");
                t.setAttribute("width","218");
                t.setAttribute("border","0");
                t.setAttribute("cellpadding","0");
                t.setAttribute("cellspacing","0");
                t.setAttribute("onmouseover",function(){this.style.backgroundColor="#CBE83E"});
                t.setAttribute("onmouseout",function(){this.style.backgroundColor="#FFFFFF"});
                var row=document.createElement("tr")
                var cell1 =document.createElement("td");
                var a=document.createElement("a");
                a.setAttribute("href","show?id="+text);
                a.setAttribute("target","_blank");
                var img1 =document.createElement("img");
                img1.setAttribute("src",text2);
                a.appendChild(img1);
                cell1.appendChild(a);//
                row.appendChild(cell1);
                t.appendChild(row);//
                var row1=document.createElement("tr")
                var cell2 =document.createElement("td");
                cell2.setAttribute("height","60");
                cell2.setAttribute("width","100%");
                cell2.setAttribute("align","right");
                cell2.setAttribute("class","photoTitle");
    var divc =document.createElement("div"); //创建一个DIV一个节点
                var tableNode=document.createTextNode(text1); //创建一个文本节点
                var a1=document.createElement("a")
                a1.setAttribute("href","show?id"+text);
                a1.setAttribute("target","_blank");
                var f=document.createElement("font")//创建一个字节点
                f.setAttribute("face","Arial");
                f.appendChild(tableNode);
                a1.appendChild(f);
                divc.appendChild(a1);
                cell2.appendChild(divc);//把文本赋值给cell
                cell2.setAttribute("class","photoTitle");
                row1.appendChild(cell2);
                t.appendChild(row1);//
                cell.appendChild(t);//
                alert(text2 +'\n\n'+ cell.outerHTML);
    //            return cell;            document.getElementById('mp').innerHTML = cell.outerHTML;
                
    </script>