图片长与宽不好获取的,自己来这个网站找找看有没有例子代码下载:http://www.sinlo.com

解决方案 »

  1.   


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>html-www.51windows.Net</title>
    </head>
    <body>
    <script>
    var img=null;
    function s()
    {
    if(img)img.removeNode(true);
    img=document.createElement("img");
    img.style.position="absolute";
    img.style.visibility="hidden";
    img.attachEvent("onreadystatechange",orsc);
    img.attachEvent("onerror",oe);
    document.body.insertAdjacentElement("beforeend",img);
    img.src=inp.value;
    }
    function oe()
    {
    alert("cant load img");
    }
    function orsc()
    {
    if(img.readyState!="complete")return false;
    alert("高:"+img.offsetHeight+"\n宽:"+img.offsetWidth);
    }
    </script>
    <input type="file" Name="file" id="inp" value="默认值"><br><input onclick="s()" type="button" value="点我一下给出要上传图片的大小及长、宽" name="button"></body>
    </html>
     
    <div style="position: absolute; bottom: 10; right: 0; width: 150; height: 18;cursor:hand;z-index:100000;font:menu;background:infobackground;border:1 solid #999999;padding:4px;">
     <A href="/data/" target=_blank><FONT color=red> DataCenter</FONT></A>  <A href="/game/" target=_blank><FONT color=green> 在线小游戏</FONT></A>
     <input type="button" name="Button" value="源代码" onClick= 'window.location = "view-source:" + window.location.href'><SCRIPT LANGUAGE="JavaScript" src="/log/sitelog.asp"></SCRIPT></div>
    <!-- 海娃@[email protected]@无忧视窗@http://www.51windows.net -->
      

  2.   

    var imgSize={
    width=0,
    height=0
    }var GetImgSize=function(obj){
    var img=new Image();
    img.src=obj;
    imgSize.width=obj.offsetWidth;
    imgSize.height=obj.offsetHeight;
    return imgSize;
    }
      

  3.   

    把obj.offsetWidth改成img.width;