//图片大小自动脚本 function AutoResizeImage(maxWidth, maxHeight, objImg) { var img = new Image(); img.src = objImg.src; var hRatio; var wRatio; var Ratio = 1; var w = img.width; var h = img.height; wRatio = maxWidth / w; hRatio = maxHeight / h; if (maxWidth…
1.js中定义一个变量i,判断i的取值在[1,3]中的错误写法 if(1<= i <= 3) 假设js的值为4,浏览器在解析js时会先将1与4比较 ,显然1<= 4,返回结果为1,然后在拿返回结果1与3比较,返回结果为1.所以会出现4在[1,3]之间的错误 2.正确的写法 if(1<= i && i <=3)…
<script> function dlutChangeImg(){ var maxwidth = 598; var obj = document.getElementById('bbs_font_size'); var imgs = obj.getElementsByTagName('img'); for(var i=0; i<imgs.length; i++){ var img = imgs[i]; var width = img.width; var height = img.he…