Dynamic Images: Zooming Images by Name
Zooming Images by Name
doing the advisable
More often than not, this is the routine that will be used. However, it is also the only routine that may involve intervention into the HTML of an already existing document. If the document does not have a coherent image NAMEing scheme, we will have to go and give each of the images that we want to be zoomable in a page a unique identifier. It is advisable that all zoomable images are given a prefix, for example "imZ".
We do not have to name all our images, just the ones that will be zoomed. In our code we will check first to see if the image has a name at all.
Given what we have discussed so far, it should be elementary to produce the one line that will identify our image as zoomable.
Define a prefix
First, however, let's define a variable to hold the substring (prefix) that we will search for in the name.
- useName = "imZ"
- useMap = null;
Our much-maligned findIt function now reads:
- function findIt(e) {
if (zoomed) {
zoomIn();
return false;
}
if (IE4) {
isImage = (event.srcElement.tagName == "IMG") ? 1 : 0;
isName = (event.srcElement.name && event.srcElement.name.indexOf(useName) != -1) ? 1 : 0;
// check for existence of name and prefix
isOK = (isImage && isName)
if (isOK) {
whichIm = event.srcElement;
zoomOutInPage();
return false;
}
}
else {
if (e.target=="[object Image]") {
whichIm = e.target;
gotIt = true;
}
else {
l = e.pageX; t = e.pageY;
gotIt = getImage(l,t);
}
if (gotit) {
gotIt = (whichIm.name && whichIm.name.indexOf(useName) != -1) ? 1 : 0;
isGIF = (justGIFs && whichIm.src.indexOf(".gif") != -1) ? 1 : 0;
}
if (gotIt) { zoomOutInEl(); return false }
}
return true
}
<A NAME="imBigGuy">
<IMG
NAME="imZJup" SRC="jupiter.jpeg" WIDTH=80 HEIGHT=60 HSPACE=20 ALIGN=LEFT></A>
<A HREF="/3d/lesson17/">
<IMG
NAME="imZFruit" SRC="3d.jpg" WIDTH=80 HEIGHT=60 HSPACE=20 ALIGN=LEFT BORDER=0></A>
<A HREF="/outlook/column5/">
<IMG
NAME="imRich" SRC="richWig.gif" WIDTH=80 HEIGHT=60 HSPACE=20 BORDER=0></A>
This method is the recommended method. We will cover one last feature: making sure the zoomed image stays within your display window.
Produced by Peter Belesis and
All Rights Reserved. Legal Notices.Created: 08/27/97
Revised: 09/28/97
URL: https://www.webreference.com/dhtml/column3/byName.html