n'abend,``
Hallo, ich habe da eine kleine Frage bezüglich einer Javascript Funktion. Ich hab mir da was zusammengesponnen, aber es funktioniert nicht (wieso auch^^) da das ganze nur aus Copy and Paste entstanden ist :P
»Copy and Paste« hat halt sehr oft den Nachteil, dass man *keine* Ahnung hat, was man da eigentlich gerade zusammenstückelt.
function resize( image )
{
// tolerated space used on screen (in percent)
var tolerated = 50;
// resize image if it's wider than tolerated
if ( image.width > ( screen.width / 100 ) * tolerated )
{
var actualWidth = image.width;
var actualHeight = image.height;
// adjust width to fit in tolerated space
image.width = image.width / ( image.width / ( (screen.width / 100) * tolerated ) )
// we don't need to adjust height, since browsers do that automatically
// add link to open full-size-image
image.onclick = function()
{
window.open( image.src, 'enlargedImage', 'width='+ actualWidth +',height='+ actualHeight +',scrollbars=1,toolbar=0,resizable=1,menubar=0,directories=0,status=0' );
};
}
}
<img src='{URL}' border='0' onload="resize(this)" title="Zum vergrößern auf das Bild klicken" alt="Zum vergrößern auf das Bild klicken" />
wende die Funktion resize() auf ein Bild an. Wird es "zurechtgestutzt" wird auch ein onclick-handler eingesetzt, damit das Bild in Originalgröße geöffnet werden kann.
weiterhin schönen abend...
--
#selfhtml hat ein Forum?
sh:( fo:# ch:# rl:| br:> n4:& ie:{ mo:} va:) de:] zu:} fl:( ss:? ls:[ js:|
#selfhtml hat ein Forum?
sh:( fo:# ch:# rl:| br:> n4:& ie:{ mo:} va:) de:] zu:} fl:( ss:? ls:[ js:|