zoukankan      html  css  js  c++  java
  • 【转】搜集图片操作

    1、js图片缩放

    function SetSize(obj, width, height)
    {
    myImage = new Image();
    myImage.src = obj.src;
    if (myImage.width>0 && myImage.height>0)
    {
    var rate = 1;
    if (myImage.width>width || myImage.height>height)
    {
    if (width/myImage.width<height/myImage.height)
    {
    rate = width/myImage.width;
    }
    else
    {
    rate = height/myImage.height;
    }
    }
    if (window.navigator.appName == "Microsoft Internet Explorer")
    {
    obj.style.zoom = rate;
    }
    else
    {
    obj.width = myImage.width*rate;
    obj.height = myImage.height*rate;
    }
    }
    }

    用法:


    <img src="img/offer/41936519.jpg" border="0" style="zoom: 0.1" onload="SetSize(this, 80, 60)"/>

    这种方法在IE、FIREFOX、OPERA、NETSCAPE测试都适用。

  • 相关阅读:
    第九章:switch语句
    第八章:if-else语句
    第七章:运算符及运用
    第六章:名命规范
    事务
    jdbc
    Object
    容器
    Java exception
    Java OO1
  • 原文地址:https://www.cnblogs.com/5tao/p/1521954.html
Copyright © 2011-2022 走看看