Suche im Forum:
Suchen


Autor Nachricht
Beitrag19.01.2012 um 21:04 (UTC)    
Titel:

Ok jetzt habe ich es verstanden. Du hast recht, ich bin davon ausgegangen, dass alle Bilder die gleiche größe haben. Wenn du die Breite und die Höhe als inlene-Style, des Imagetag definierst, braucht man nicht sehr viel ändern:
Zitat:
<img src="URL zum Bild" alt="irgendwas" class="o4nimagesizechanger" style="width:XXpx; height:XXpx;">

Breite in Pixel
Höhe in Pixel

Script mit Änderungen:
Zitat:
<script type="text/javascript">
var steps = 25;

var i, temp, temp2;

temp = document.getElementsByTagName('img');

for(i = 0; i < temp.length; i++) {
if(temp[i].className && temp[i].className == 'o4nimagesizechanger'){
temp2 = new Image();
temp2.src = temp[i].src;
temp[i].minWidth = parseInt(temp[i].style.width);
temp[i].acWidth = temp[i].minWidth;
temp[i].maxWidth = temp2.width;
temp[i].minHeight = parseInt(temp[i].style.height);
temp[i].acHeight = temp[i].minHeight;
temp[i].maxHeight = temp2.height;
temp[i].timeOut = null;
temp[i].makeItBigger = function () {
var obj = this;

if(this.timeOut)
window.clearTimeout(this.timeOut);

((this.acWidth + steps) < this.maxWidth) ? this.acWidth += steps : this.acWidth += (this.maxWidth - this.acWidth);

this.style.width = this.acWidth + 'px';

((this.acHeight + steps) < this.maxHeight) ? this.acHeight += steps : this.acHeight += (this.maxHeight - this.acHeight);

this.style.height = this.acHeight + 'px';

if((this.acHeight < this.maxHeight) || (this.acWidth < this.maxWidth))
this.timeOut = window.setTimeout(function(){obj.makeItBigger();}, 200);
};
temp[i].makeItSmaller = function () {
var obj = this;

if(this.timeOut)
window.clearTimeout(this.timeOut);

((this.acWidth - steps) > this.minWidth) ? this.acWidth -= steps : this.acWidth -= (this.acWidth - this.minWidth);

this.style.width = this.acWidth + 'px';

((this.acHeight - steps) > this.minHeight) ? this.acHeight -= steps : this.acHeight -= (this.acHeight - this.minHeight);

this.style.height = this.acHeight + 'px';

if((this.acHeight > this.minHeight) || (this.acWidth > this.minWidth))
this.timeOut = window.setTimeout(function(){obj.makeItSmaller();}, 200);
};
temp[i].onmouseover = temp[i].makeItBigger;
temp[i].onmouseout = temp[i].makeItSmaller;
}
}
</script>

Wie du siehst, musst du jetzt nur noch die Anzahl der Pixel, um die das Bild vergrößert/verkleinert wird eintragen.
______________
mfg
o-4-n

"If you’re incompetent, you can’t know you’re incompetent." - [David Dunning]

*** Die Suchfunktion ist KEINE tödliche Krankheit! ***

Eventplanung, Equipment, Zeltverleih, Catering
Beiträge der letzten Zeit anzeigen:   


Powered by phpBB © 2001, 2005 phpBB Group
Deutsche Übersetzung von phpBB.de