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)"/>

  

相关文章:

  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-12-23
  • 2021-10-12
  • 2021-06-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
  • 2021-12-23
  • 2021-12-31
  • 2021-07-22
相关资源
相似解决方案