コードをコピー コードは次のとおりです。 head> <br>/* デバイスが PC であるかどうかを判断します */ <br>function isPC() { <br>var userAgentInfo = navigator.userAgent; 🎜>var Agents = new Array("Android", "iPhone", "SymbianOS","Windows Phone", "iPad", "iPod"); <br>var flag = true; 0; v < Agents.length; v ) { <BR>if (userAgentInfo.indexOf(Agents[v]) > 0) { <BR>break; } <BR>戻りフラグ; <BR>} <BR><BR>/* 画像サイズの調整*/ <BR>function AutoResizeImage(maxWidth, maxHeight, objImg) { <BR>var img = new Image(); >img.src = objImg.src; <BR>var wRatio; <BR>var w = img.height; 🎜>wRatio = maxWidth / w; <br>hRatio = maxHeight / h; <br>if (maxWidth == 0 && maxHeight == 0) { <BR>Ratio = 1; else if (maxWidth == 0) { // <BR>if (hRatio <1) Ratio = hRatio; <BR>} else if (maxHeight == 0) { <BR>if (wRatio <1) Ratio = wRatio; else if (wRatio < ; 1 || hRatio < 1) { <BR>Ratio = (wRatio <= hRatio ? wRatio : hRatio); <BR>if (Ratio < 1) { <BR> w = w * 比率; <BR>h = h * 比率; <BR>objImg.height = h; <BR><BR>/* セットさまざまなデバイスのスケーリング戦略 */ <BR>function setImg(tagid,pcWidth,pcHeight,appWidth,appHeight){ <BR>var tag=document.getElementById(tagid); <BR>var image=tag.getElementsByTagName("img "); <BR> for(var i=0;i<images.length;i ){ <BR>if(isPC){ <BR>AutoResizeImage(pcWidth, pcHeight, Images[i]); <BR>}else { <BR>AutoResizeImage( appWidth, appHeight, image[i]); <BR>} <BR>} <BR>} <BR>window.onload=function(){ <BR>setImg('imgDIV',300, 0,300,0); <BR>} <BR><br><body><br><BR> img alt="" src = "http://192.168 .1.116:9999/ffzx/news/20140208/1386835169183.jpg" /> <br></div> </body> <br></html> <br><br><br> </div>