Copy Code code as follows:
<div id=article></div" >
<script type= "Text/javascript" >
Scale pictures to fit size
function Resizeimages ()
{
var myimg,oldwidth,oldheight;
var maxwidth=550;
var maxheight=880
var IMGs = document.getElementById (' article '). getElementsByTagName (' img '); If you have defined an ID that is not article, please modify it here
for (i=0;imyimg = Imgs[i];
if (Myimg.width > Myimg.height)
{
if (Myimg.width > MaxWidth)
{
OldWidth = Myimg.width;
Myimg.height = Myimg.height * (maxwidth/oldwidth);
Myimg.width = MaxWidth;
}
}else{
if (Myimg.height > MaxHeight)
{
OldHeight = Myimg.height;
Myimg.width = Myimg.width * (maxheight/oldheight);
Myimg.height = MaxHeight;
}
}
}
}
Scale pictures to fit size
Resizeimages ();
</script>
It means to control the size of the picture in the specified area, or some large advertising picture will be distorted.
picture control code for cloud-dwelling communities:
Copy Code code as follows:
function Controlimg (ele,w,h) {
var c=ele.getelementsbytagname ("img");
for (Var i=0;i<c.length;i++) {
var w0=c[i].clientwidth,h0=c[i].clientheight;
var t1=w0/w,t2=h0/h;
if (t1>1| | t2>1| | w0>=600) {
C[i].width=math.floor (w0/(T1>T2?T1:T2));
C[i].height=math.floor (h0/(T1>T2?T1:T2));
if (document.all) {
C[i].outerhtml= ' <a href= ' +c[i].src+ ' target= ' _blank ' title= ' view pictures in new Window ' > ' +c[i].outerhtml+ ' </a> '
}
else{
c[i].title= "Open Picture in new Window";
C[i].onclick=function (e) {window.open (THIS.SRC)}
}
}
}
}
The ele is the specified area, W is the largest width, and larger than this will shrink. H is the maximum height.