<img src="" id=x>document.all.x.width
document.all.x.height

解决方案 »

  1.   

    <IMG SRC=imgsrc border=0 align=center onload='javascript:alert(this.width);alert(this.height)'>
    <script>
    <!--
    var flag=false;
    function DrawImage(ImgD){
       var image=new Image();
       image.src=ImgD.src;
       if(image.width>0 && image.height>0){
        flag=true;
        if(image.width/image.height>= 164/112){
         if(image.width>164){  
         ImgD.width=164;
         ImgD.height=(image.height*164)/image.width;
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         ImgD.alt=image.width+"×"+image.height;
         }
        else{
         if(image.height>112){  
         ImgD.height=112;
         ImgD.width=(image.width*112)/image.height;     
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         ImgD.alt=image.width+"×"+image.height;
         }
        }

    //-->
    </script>
     
    <a href="<%=trim(rs("picurl"))%>" target="_blank">
    <img src="<%=trim(rs("imgurl"))%>" border="0" width="164" height="112" onload="javascript:DrawImage(this);">
    </a>
      

  2.   

    <IMG SRC=imgsrc border=0 align=center onload='javascript:alert(this.width);alert(this.height)'>
    ------------------------------
    自动改变图片大小
    <script>
    <!--
    var flag=false;
    function DrawImage(ImgD){
       var image=new Image();
       image.src=ImgD.src;
       if(image.width>0 && image.height>0){
        flag=true;
        if(image.width/image.height>= 164/112){
         if(image.width>164){  
         ImgD.width=164;
         ImgD.height=(image.height*164)/image.width;
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         ImgD.alt=image.width+"×"+image.height;
         }
        else{
         if(image.height>112){  
         ImgD.height=112;
         ImgD.width=(image.width*112)/image.height;     
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         ImgD.alt=image.width+"×"+image.height;
         }
        }

    //-->
    </script>
     
    <a href="<%=trim(rs("picurl"))%>" target="_blank">
    <img src="<%=trim(rs("imgurl"))%>" border="0" width="164" height="112" onload="javascript:DrawImage(this);">
    </a>
      

  3.   

    可以用这种方式,取得上传图像的高宽 :)图像地址<input type="file" onchange="img.src=this.value">
    高<input type="text" name="h">
    宽<input type="text" name="w">
    <div style="position:absolute;top:;left:0;visibility:hidden">
    <img id="img" onload="Show(this)">
    </div>
    <script language="JavaScript">
    function Show(oImg)
    {
        document.all.h.value=oImg.height;
        document.all.w.value=oImg.width;
    }
    </script>
      

  4.   

    谢谢wanghr100(灰豆宝宝.net(魔幻季节)) 了,要的就是你说的这情况情况的代码,非常感谢。非常感谢