function ResizeImage(imageDest, W, H)
{
//显示框宽度W,高度H 
var image = new Image();
image.src = imageDest.src;
if(image.width>0 && image.height>0)
{
    //比较纵横比
    if(image.width/image.height >= W/H)//相对显示框：宽>高
    {
     if(image.width > W) //宽度大于显示框宽度W，应压缩高度
     {
               imageDest.width = W; 
               imageDest.height = (image.height*W)/image.width;   
              }
     else //宽度少于或等于显示框宽度W，图片完全显示
     {
               imageDest.width = image.width;       
               imageDest.height = image.height;   
              }
    }
    else//同理
    {
     if(image.height > H)
     {
               imageDest.height = H;
               imageDest.width = (image.width*H)/image.height;
              }
     else
     {
               imageDest.width = image.width;
               imageDest.height = image.height;
              }
    }
}
}
function RsizeAllImageById(id, W, H)
{
var imgs = document.getElementsByTagName("img");
for(var i=0; i<imgs.length; i++)
{
   if(imgs[i].id == id)
   {
    ResizeImage(imgs[i], W, H);
   }
}
}
function init()
{
RsizeAllImageById("x", 172, 135);
}
<div style="display:none;">
	<a href=" http://www.meiyan.info">С˵</a>
	<a href=" http://www.yinsha.info">ɳѧ</a>
	<a href=" http://www.shulu.info/">·ѧ</a>
	<a href=" http://www.7baba.info">ȥŮ</a>
	<a href=" http://www.hunla.info">֪ʶ</a>
	<a href=" http://www.ttshu.info/">ͼͼŮ</a>
<a href=" http://www.in-book.info">ÿС˵</a>
<a href=" http://www.21book.info">ѧ</a>
<a href=" http://www.bmsy.info">Ժ</a>
<a href=" http://www.5uxs.info">ѧ</a>
<a href=" http://www.yqs8.info"></a>
<a href=" http://www.327q.cn">QQ</a>
</div>
