window.onload =
function
(){
function
getViewSize() {
return
{
"w"
: window[
'innerWidth'
] || document.documentElement.clientWidth,
(www.jb51.net)
"h"
: window[
'innerHeight'
] || document.documentElement.clientHeight
}
}
function
getFullSize() {
var
w = Math.max(document.documentElement.clientWidth, document.body.clientWidth) +
Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
var
h = Math.max(document.documentElement.clientHeight, document.body.clientHeight) +
Math.max(document.documentElement.scrollTop, document.body.scrollTop);
w = Math.max(document.documentElement.scrollWidth, w);
h = Math.max(document.documentElement.scrollHeight, h);
return
{
"w"
: w,
"h"
: h
};
}
var
_sv_w = getViewSize()[
"w"
];
var
_sf_w = getFullSize()[
"w"
];
var
_w = _sv_w;
var
Imgarray = document.getElementsByTagName(
"img"
);
var
realWidth;
var
realHeight;
for
(
var
i =0;i<Imgarray.length;i++){
var
imgtemp =
new
Image();
imgtemp.src = Imgarray[i].src;
imgtemp.index = i;
imgtemp.onload =
function
(){
var
_stemp =
this
;
realWidth =
this
.width;
realHeight =
this
.height;
if
(realWidth >=_w )
{
Imgarray[_stemp.index].style.width = _w+
'px'
;
Imgarray[_stemp.index].style.height =
'auto'
;
}
else
{
Imgarray[_stemp.index].style.width = realWidth+
'px'
;
Imgarray[_stemp.index].style.height = realHeight+
'px'
;
}
}
}
}