Picture scaled (CSS mandatory) JS code

Source: Internet
Author: User

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Map page Special effects code </title>

<style>
<!--, in many cases, the use of this method will increase the IE load. -->
. thumbimage {
max-width:50px;
max-height:50px;
}
* HTML. Thumbimage {
Width:expression (This.width > && this.width > This.height 50:true);
Height:expresion (This.height > 50:true);
}

</style>

<body>

</body>


Yahoo picture's scaled down code::


<script type= "text/web Effects" >
function Setimgsize (img,width,height) {
var maxwidth=width;//set Picture width limit
var maxheight=height;//set Picture height limit
var heightwidth=img.offsetheight/img.offsetwidth;//set aspect ratio
var widthheight=img.offsetwidth/img.offsetheight;//set ratio of width to height
if (img.offsetwidth>maxwidth) {
Img.width=maxwidth;
Img.height=maxwidth*heightwidth;
}
if (img.offsetheight>maxheight) {
Img.height=maxheight;
Img.width=maxheight*widthheight;
}
}

</script>


Use:

<script language= "Web Effects" >
<!--
var flag=false;
Function DrawImage (IMGD) {
var image=new image ();
Image.src=imgd.src;
if (image.width>0 && image.height>0) {
Flag=true;
if (image.width/image.height>= 180/110) {
  if (image.width>180) {
   imgd.width=180;
   imgd.height= (image.height*110)/image.width;
 }else{
   imgd.width=image.width;
   imgd.height=image.height;
 }
 /*imgd.alt= "bigpic" */
}
else{
  if (image.height>110) {
   imgd.height=110 ;
   imgd.width= (image.width*110)/image.height;
 }else{
   imgd.width=image.width;
   imgd.height=image.height;
 }
  /*imgd.alt= "Bigpic"/
}
}
}
//-->
</script>

Method Four (CSS mandatory) JS code


<script type= "Text/javascript" >
function Resizeimage (obj) {
Obj.width = obj.width > && obj.width > Obj.height? 50:auto;
Obj.height = obj.height > 50? 50:auto;
}
</script>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.