Jorwangの small Horn: "Recently busier Ah, temporarily do not update, we play a little bit Oh!" O (∩_∩) o~ "
Just see two control page picture width of the method, feel very good very convenient, hereby share to everyone.
The first approach is to use CSS to achieve control size:
img{
border:0;
margin:0;
padding:0;
max-width:590px;
Width:expression (this.width>590?) 590px ": this.width); max-height:590px;
Height:expression (this.height>590?) 590px ": this.height);
}
If you want to be compatible with IE6, you can use the JavaScript script described previously.
The second approach is to use JavaScript to control the size of the page picture width:
function set_img_size (obj, width) {if (!obj) return;
if (!width) {width = obj.clientwidth * 0.9; if (width <) return; /* Set the picture's limited width */} Img_items = Obj.getelementsbytagname ("img") if (Img_items) {for (i=0; i<img_i Tems.length;
i++) {var s_width = img_items[i].width;
var s_height = img_items[i].height;
if (s_width > width) {img_items[i].style.width = width + "px"; if (s_height = = img_items[i].height) {img_items[i].style.height = ((width/s_width) * img_items[i].h
Eight) + "px";
} Img_items[i].onclick = function () {window.open (THIS.SRC)};
Img_items[i].style.cursor = "pointer";
Img_items[i].alt = "Click to view original Size"; function Selfadaptation_size () {if (typeof (content_img_width) = = ' undefined ') set_img _size (DOCUMENT.GETELEMENTBYid ("posts")); /* Control the image of the element ID number */Else Set_img_size (document.getElementById ("posts"), content_img_width); /* Control the image of the element ID number/set_img_size (document.getElementById ("Custom"));
/* Control the image of the element ID number */} if (Window.addeventlistener) window.addeventlistener ("Load", selfadaptation_size, false);
else if (window.attachevent) window.attachevent ("onload", selfadaptation_size); else window.onload = selfadaptation_size;
If you have a better and more concise way, share it with me, thank you!