Die Codekopie lautet wie folgt:
<div id = article> <img src = "/down/js/bilder/12498880470.jpg"/> </div>
<script type = "text/javaScript">
// Skalieren Sie das Bild auf die entsprechende Größe
Funktion rsizeimages ()
{
var myimg, Oldwidth, Oldheight;
var maxwidth = 550;
var maxHeight = 880
var imgs = document.getElementById ('Artikel'). GetElementsByTagName ('IMG');
für (i = 0; i <imgs.length; i ++) {
myimg = imgs [i];
if (myimg.width> myimg.height)
{
if (myimg.width> maxwidth)
{
OldWidth = Myimg.width;
myimg.height = myimg.height * (maxwidth/OldWidth);
myimg.width = maxwidth;
}
}anders{
if (myimg.height> maxheight)
{
OldHeight = Myimg.Height;
myimg.width = myimg.width * (MaxHeight/OldHeight);
myimg.height = maxheight;
}
}
}
}
// Skalieren Sie das Bild auf die entsprechende Größe
REHRIZEIMAGES ();
</script>
Es bedeutet, die Größe des Bildes im angegebenen Bereich zu steuern, ansonsten werden einige größere Werbebilder ebenfalls verformen.
Der von Wulin.com verwendete Bildkontrollcode:
Die Codekopie lautet wie folgt:
Funktion kontrollimg (ele, w, h) {
var c = ele.getElementsByTagName ("img");
für (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 = "_ leer">'+c [i] .outerhtml+'</a>' '
}
anders{
c [i] .title = "Öffnen Sie das Bild im neuen Fenster";
c [i] .onclick = function (e) {window.open (this.src)}}
}
}
}
}
ELE ist der angegebene Bereich, W ist die maximale Breite und wird reduziert, wenn er größer ist. H ist die maximale Höhe.