Tip: you can modify some code before running
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>The image size is reduced proportionally when the specified width is exceeded.</title><meta http-equiv="content-type" content="text/html;charset=gb2312"></head><body><!--把下面代码加到<body>与</body>之间--><p>Loading images ......</p><p></p><script type="text/javascript">Var aP = document. getElementsByTagName ("p"); var oImg = document. getElementsByTagName ("img") [0]; var oNewImg = new Image (); var minWidth = 300; oNewImg. onload = function () {oImg. src = this. src; var iWidth = oImg. offsetWidth; var iHeight = oImg. offsetHeight; oImg. style. width = (iWidth> minWidth? MinWidth: iWidth) + "px"; // oImg. style. height = iHeight * oImg. style. width/iWidth + "px"; aP [0]. innerHTML = "original image ratio: width" + iWidth + "px, height:" + iHeight + "px, click to view the original image"; aP [1]. innerHTML = "thumbnail ratio: width" + oImg. offsetWidth + "px, height:" + oImg. offsetHeight + "px" ;}; oNewImg. onerror = function () {aP [0]. innerHTML = "image loading failed. Please use the correct image address! ";} ONewImg. src =" http://www.zzsky.cn/images/zzsky_468.gif ";</script></body></html>
Tip: you can modify some code before running