Javascript Image Resize

前端 未结 13 1350
南旧
南旧 2020-11-28 23:03

Does anyone know how to resize images proportionally using JavaScript?

I have tried to modify the DOM by adding attributes height and width

相关标签:
13条回答
  • 2020-11-29 00:08

    Tried the following code, worked OK on IE6 on WinXP Pro SP3.

    function Resize(imgId)
    {
      var img = document.getElementById(imgId);
      var w = img.width, h = img.height;
      w /= 2; h /= 2;
      img.width = w; img.height = h;
    }
    

    Also OK in FF3 and Opera 9.26.

    0 讨论(0)
提交回复
热议问题