Mostrando Codigo - Dhtml
EXPLICACION
Debemos moficar /images/mundo.gif por la imagen que quieras.
function resizeImage (imageOrImageName, width, height) {
var image = typeof imageOrImageName == 'string' ?
document[imageOrImageName] : imageOrImageName;
if (document.layers) {
image.currentWidth = width;
image.currentHeight = height;
var layerWidth = image.width > width ? image.width : width;
var layerHeight = image.height > height ? image.height : height;
if (!image.overLayer) {
var l = image.overLayer = new Layer(layerWidth);
}
var l = image.overLayer;
l.bgColor = document.bgColor;
l.clip.width = layerWidth;
l.clip.height = layerHeight;
l.left = image.x;
l.top = image.y;
var html = '';
html += '
<IMG SRC = "' + image.src + '" ';
html += image.name ? ' NAME = "overLayer' + image.name + '" ' : ' ';
html += ' WIDTH = "' + width + '" HEIGHT = "' + height + '" > ';
l.document.open();
l.document.write(html);
l.document.close();
l.visibility = 'show';
}
else {
image.width = width;
image.height = height;
}
}
function zoomImage (imageOrImageName, factor) {
var image = typeof imageOrImageName == 'string' ?
document[imageOrImageName] : imageOrImageName;
if (document.layers) {
var currentWidth = image.currentWidth ? image.currentWidth :
image.width;
var currentHeight = image.currentHeight ? image.currentHeight :
image.height;
}
else {
var currentWidth = image.width;
var currentHeight = image.height;
}
var width = parseInt(currentWidth * factor);
var height = parseInt(currentHeight * factor);
resizeImage(image, width, height);
}
<A HREF = "javascript: resizeImage(document.images[0], 100, 100); void 0" > 100 100
</ A > |
<A HREF = "javascript: resizeImage(document.images[0], 190, 190); void 0" >
200 200
</ A > |
<A HREF = "javascript: zoomImage(document.images[0], 1.1); void 0" >
zoom + 10%
</ A > |
<A HREF = "javascript: zoomImage(document.images[0], 0.9); void 0" >
<IMG SRC = "/images/mundo.gif" >
ENLACE AL CODIGO
Si quieres enlazar desde tu pagina a este codigo
COMENTARIOS
Comentario usuario
1
5
no me funciono.
Comentario usuario
5
5
Hola laura
Descargate el código en formato de texto o obtén el codigo html de la demo
Verás como si te funciona
Saludos
Comentario usuario
3
5
me sirvio lo copie exactamente, cambie el nombre de la imagen y logro el zoom...
muchas gracias
Comentario usuario
4
5
ok, esta bueno el código, me sirvió el script,muchas gracias
Comentario usuario
1
5
SI sirve pero sólo para una imagen, para varias nó, porqué?