首页 | IT新闻 | 硬件 | 操作系统 | 开发 | 网络编程 | 数据库 | 热门框架 | 网络安全 | 组网 | 建站指南 | 网页制作 | 特效 | 实用技巧 | 服务器 | 办公 | QQ | 探索 | 社区

  • 技术部落
  • 部落首页 > 网页特效 > 正文
  • 自动显示图片属性
      2007-2-25  来源:网络资源  编辑:Jsbulo  热度:

    脚本说明:
    第一步:把如下代码加入<head>区域中
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function checkImage(loc) {
    loc = "image-popup.html?" + loc;
    windowprops = ’menubar=0,toolbar=0,status=0,location=0’;
    popupWindow = open(loc, ’previewWin’, windowprops);
    if (popupWindow.opener == null)
    popupWindow.opener = self;
    }
    //  End -->
    </script>

     

    第二步:把如下代码加入<body>区域中
    <form name=dimform>
    请输入你所要显示的图片的路径:<br>
    <input type=text name=url size=40 value="http://">
    <input type=button value="OK" onClick="checkImage(this.form.url.value);">
    <p>
    检测结果:<p>
    宽度 = <input type=text name=width><br>
    高度 = <input type=text name=height>
    </form>

     

     

    第三步:新建image-popup.html的文件,其代码如下:
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript1.1">
    <!-- Begin
    imageerror = 0;
    function allDone() {
    width = (!imageerror) ? document.images[0].width : "error";
    height = (!imageerror) ? document.images[0].height : "error";
    opener.document.dimform.width.value = width;
    opener.document.dimform.height.value = height;
    timerID = window.setTimeout(’window.close();’, 2000);
    }
    function complain() {
    imageerror = 1;
    alert(’Error loading that image.  Please correct the image URL and try again.’);
    timerID = window.setTimeout(’window.close();’, 2000);}
    // End -->
    </SCRIPT>
    </HEAD>
    <BODY onLoad="allDone();">
    <script language="JavaScript">
    <!-- Begin
    query = location.search;
    url = query.substring(1, query.length);
    document.write("<img src=’" + url + "’ onError=’complain();’>");
    // End -->
    </script>
    <P>
    Loading image....  Reading dimensions....
    <script language="Javascript">
    document.write("<img src=’http://counter.yesky.com/counter.shtml?CID=54197&AID=-1&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+"’ border=’0’ alt=’’ width=’0’ height=’0’>");
    </script>
    <noscript>
    <img src="http://counter.yesky.com/counter.shtml?CID=54197&AID=-1&refer=noscriptcounter&cur=noscriptcounter" border=’0’ width=’0’ height=’0’/>
    </noscript><IFRAME frameBorder=0 scrolling=no src="http://homepage.yesky.com/b_contentsd.html" width=600 height=170></IFRAME></body>
    </HTML>

    相关链接