<script language="JavaScript">
<!--
function mdImg(path,title)
{
var text = "";
if(!path)path = "";
if(!title)title = '图片名称';
text += '<img src="'+path+'" onclick="alert(\''+title+'\')">';
test.innerHTML = text;
}
-->
</script>
<button onClick="mdImg()">test</button>
<div id="test"></div>

解决方案 »

  1.   

    <script>
    function showpic(url,name)
    {
       document.innerHTML=document.innerHTML+"<img src='"+url+"'" border='0' onclick=window.open('about:"+name+"')>";
    }
    </script><input type="button" onclik="showpic('xxx.gif','my friend')" value="click me">
      

  2.   

    <script>
    function showpic(url,name)
    {
       xx=document.createElement("<img src='"+url+"'" border='0' onclick=window.open('about:"+name+"')>");
    document.body.appenChild(xx)
    }
    </script><input type="button" onclik="showpic('xxx.gif','my friend')" value="click me">
      

  3.   

    sandyuk(冰の沙隆) :
    我想把你的程序改一下,加上table之类的,让它有点约束的,但是我不会改,请看我改的哪里有错?<script language="JavaScript">
    <!--function mdImg(path,title)
    {
    var text = "";
    if(!path)path = "";
    if(!title)title = 'c:\1.bmp';
    text +=<DIV align=center id=floater>
                    <TABLE height=10 width=24>
                     <TBODY>
                      <TR>
                       <TD align=middle height=6 vAlign=center width=76>
                         <img  border=0 src="1.bmp" onclick="alert(\''+title+'\')">';
                       </TD>  
                      </TR>
                     </TBODY>
                   </TABLE>
                  </DIV>
    test.innerHTML = text;
    }
    -->
    </script><button onClick="mdImg()">test</button>
    <div id="test"></div>
    我也知道text += 那里有错,不知如何改。请大侠再帮帮忙。