var img=new image();
img.src='图片URL';

解决方案 »

  1.   

    ………………
    就凭你用我的留言板该自己的留言板,你也该给我1000分,哈哈~~~~<script language="JavaScript">
    <!--
    function changepic(value)
    {
    this.document.words.pic.src="images/"+value+".gif";
    }
    function selectpic(value)
    {
    this.document.words.head.selectedIndex = value - 1;
    changepic(value);
    document.all.headpic.style.visibility="hidden";
    }
    //-->
    </script>
    <a href="#" onclick="javascript:document.all.headpic.style.visibility='visible';document.all.post.style.visibility='hidden';">查看全部头像</a><div id="headpic" style="position:absolute; left:212px; top:61px; width:235px; height:99px; z-index:2; overflow: visible; visibility: hidden;"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableborder">
        <tr> 
          <td align="right"><a href="#" onclick="javascript:document.all.headpic.style.visibility='hidden';document.all.post.style.visibility='visible';">关闭-<strong>X</strong></a> 
          </td>
        </tr>
        <tr>
          <td><a href="#" onClick="selectpic(1)"><img src="1.gif" border="0" width="72" height="72"></a>
    <a href="#" onClick="selectpic(2)"><img src="2.gif" border="0" width="72" height="72"></a>
    <a href="#" onClick="selectpic(3)"><img src="3.gif" border="0" width="72" height="72"></a></td>
        </tr>
      </table>
    </div>
      

  2.   

    改了还是不行啊。。总是选了不能变换。应该怎么弄呢?
    这是选择头像一块的代码
    <script>
    function changepic(value)
    {
    this.document.form.pic.src="head/em"+value+".gif";
    }
    </script>
                <table width="28%" border="0" align="center" cellpadding="0" cellspacing="0" >
                  <tr>
                    <td width="20%"> 头像:</td>
                    <td width="80%" ><select name="head" class=textbox onChange="changepic(this.document.form.head.value)">
             <%
                i=1
                   do while i <= 5
    slt = ""
    if i = Cint(request.QueryString("pic")) then 
    slt = "selected"
    end if
                          %>
                        <option value="<%=i%>" <%=slt%>><%=i%></option>
                        <%
                            i=i+1
                            loop
    if request.QueryString("pic")="" then
    pic = 1
    else
    pic = Cint(request.QueryString("pic"))
    end if
                         %>
                      </select>
                      <img src="head/em<%=pic%>.gif" width="26" height="26" id="pic" align="absmiddle">(<a href="head.asp" >选择更多头像</a>)</td>
                  </tr>
                </table></TD>
            </TR>
    我的头像都保存在主目录下的head文件夹里 名字都叫em1.gif....依次为2、3....
    能帮帮忙改一下么?就是那中你所说的隐藏层的方法!谢谢了
    我现在给帖子加分!
      

  3.   

    …………………………还说不是我的呢~~~em1.gif,em2.gif是最早我论坛上我那头像用的名字~~~~呵呵~~~无所谓啦~~~用我这个流言板做原形的满天飞~~~~head.asp那个页面已经没用了~~~~PS:既然你这么喜欢我这个流言板,我可能过几天再仿照现在PHP的这套写一套ASP的来~~~~<script language="JavaScript">
    <!--
    function changepic(value)
    {
    this.document.form.pic.src="images/"+value+".gif";
    }
    function selectpic(value)
    {
    this.document.form.head.selectedIndex = value - 1;
    changepic(value);
    document.all.headpic.style.visibility="hidden";
    }
    //-->
    </script>            <table width="28%" border="0" align="center" cellpadding="0" cellspacing="0" >
                  <tr>
                    <td width="20%"> 头像:</td>
                    <td width="80%" ><select name="head" class=textbox onChange="changepic(this.document.form.head.value)">
             <%
                i=1
                   do while i <= 5
    slt = ""
    if i = Cint(request.QueryString("pic")) then 
    slt = "selected"
    end if
                          %>
                        <option value="<%=i%>" <%=slt%>><%=i%></option>
                        <%
                            i=i+1
                            loop
    if request.QueryString("pic")="" then
    pic = 1
    else
    pic = Cint(request.QueryString("pic"))
    end if
                         %>
                      </select>
                      <img src="head/em<%=pic%>.gif" width="26" height="26" id="pic" align="absmiddle">(<a href="#" onclick="javascript:document.all.headpic.style.visibility='visible';document.all.post.style.visibility='hidden';">查看全部头像</a>
    )</td>
                  </tr>
                </table></TD>
            </TR><div id="headpic" style="position:absolute; left:212px; top:61px; width:235px; height:99px; z-index:2; overflow: visible; visibility: hidden;"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableborder">
        <tr> 
          <td align="right"><a href="#" onclick="javascript:document.all.headpic.style.visibility='hidden';document.all.post.style.visibility='visible';">关闭-<strong>X</strong></a> 
          </td>
        </tr>
        <tr>
          <td>
    <%
    i = 0
    do while i < 40
    %><a href="#" onClick="selectpic(<%=i%>)"><img src="<%=i%>.gif" border="0" width="72" height="72"></a>
    <%
    loop
    %>
    </td>
        </tr>
      </table>
    </div>