Javascript proportional scaling of images in a specified area to achieve original integrated version of the script home

Source: Internet
Author: User

This article is a collection of scripts. You are welcome to reprint this article. Copy codeThe Code is 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 ){
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 =" open an image in a new window ">' + c [I]. outerHTML + '</a>'
}
Else {
C [I]. title = "opening an image in a new window ";
C [I]. onclick = function (e) {window. open (this. src )}
}
}
}
}
Window. onload = function (){
ControlImg (document. getElementById ("content"), 670,980 );
}

This code was used in the past, but because the specific ideas are not clear, I have sorted out the articles I saw in blueidea today.
The image in the specified area is generally used to control the content part. You can use the content in controlImg (document. getElementById ("content"), 670,980); below is the test code.<Br/> The following is the region to be controlled. </P> source image <center> </center> <br/> tutorial layer: <br/> 1. Copy the source image layer <br/> 2. Execute the layer <new adjustment layer <color/saturation parameters are not described <br/> 3. Execute the layer <new adjustment layer <Curve <br/> four colors and then reduced opacity <br/> five layers <new adjustment layer <brightness/contrast <center> </center> <p> The following is not subject to control, for more information, see. <Br/> source image <center> </center> <br/> tutorial layer: <br/> 1. Copy the source image layer <br/> 2. Execute the layer <new adjustment layer <color/saturation parameters are not described <br/> 3. Execute the layer <new adjustment layer <Curve <br/> four colors and then reduced opacity <br/> five layers <new adjustment layer <brightness/contrast <center> </center> <br/>

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.