sxn02
03-07-2003, 11:15 PM
Hello,
I try to resize a picture to fit into the available space. I wrote the zoom function based on a similar function published on this site, as well as other's work (me included).
The problem is that zoom() is never called. Moreover, sb(), which is supposed to be called onClick, is not called. Looks like I cannot access any JS function.
As HTML code, I validated it, so I'm sure that the cause is not there (errors where "missing <TITLE>", "missing ALT in IMG", and so on. With this stuff in place, still nothing happens).
I have no idea what I'm doing wrong, especially since, elsewhere, similar code is working fine. I tried with Mozilla, IE and Konqueror.
Any help would be more than welcomed.
The code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" language="JavaScript1.2">
<!--
function sb(gal,pnt)
{ parent.left.location.href='/cgi-bin/left.py?c=FFFFFF&g='+gal+'&s=0&m=7&f=0&b=3&p='+pnt;
parent.right.location.href='/cgi-bin/right.py?c=FFFFFF&g='+gal+'&s=0&m=7&f=0&b=3&p='+pnt;
};
// zoom - adapted after Image zoom in/out script - by javascriptkit.com
// found at www.javascript.com
function zoom(w,h)
{ var x=0;
var y=0;
if(document.layers)
{ x=parent.frames["right"].innerWidth-10;
y=parent.frames["right"].innerHeight-10;
}
else if(document.all)
{ x=document.body.clientWidth-10;
y=document.body.clientHeight-10;
}
if(x>0 && y>0)
{ if(w>x || h>y)
{ zf = (w/x > h/y): x/w ? y/h;
if(!document.all && !document.getElementById)
return;
d=eval("document.images.cpnt");
d.style.width=parseInt(d.style.width)*zf;
d.style.height=parseInt(d.style.height)*zf;
}
}
}
function rsz()
{ zoom(pc.width,pc.height);
}
//-->
</script>
</head>
<body onResize="rsz()">
<img id="cpnt" src="/icons/gal1/p1.jpg" onClick="sb(1,1)" border=0>
<script type="text/javascript">
<!--
var pc=document.getElementById("cpnt");
zoom(pc.width, pc.heigth);
//-->
</script>
</body>
</html>
I try to resize a picture to fit into the available space. I wrote the zoom function based on a similar function published on this site, as well as other's work (me included).
The problem is that zoom() is never called. Moreover, sb(), which is supposed to be called onClick, is not called. Looks like I cannot access any JS function.
As HTML code, I validated it, so I'm sure that the cause is not there (errors where "missing <TITLE>", "missing ALT in IMG", and so on. With this stuff in place, still nothing happens).
I have no idea what I'm doing wrong, especially since, elsewhere, similar code is working fine. I tried with Mozilla, IE and Konqueror.
Any help would be more than welcomed.
The code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" language="JavaScript1.2">
<!--
function sb(gal,pnt)
{ parent.left.location.href='/cgi-bin/left.py?c=FFFFFF&g='+gal+'&s=0&m=7&f=0&b=3&p='+pnt;
parent.right.location.href='/cgi-bin/right.py?c=FFFFFF&g='+gal+'&s=0&m=7&f=0&b=3&p='+pnt;
};
// zoom - adapted after Image zoom in/out script - by javascriptkit.com
// found at www.javascript.com
function zoom(w,h)
{ var x=0;
var y=0;
if(document.layers)
{ x=parent.frames["right"].innerWidth-10;
y=parent.frames["right"].innerHeight-10;
}
else if(document.all)
{ x=document.body.clientWidth-10;
y=document.body.clientHeight-10;
}
if(x>0 && y>0)
{ if(w>x || h>y)
{ zf = (w/x > h/y): x/w ? y/h;
if(!document.all && !document.getElementById)
return;
d=eval("document.images.cpnt");
d.style.width=parseInt(d.style.width)*zf;
d.style.height=parseInt(d.style.height)*zf;
}
}
}
function rsz()
{ zoom(pc.width,pc.height);
}
//-->
</script>
</head>
<body onResize="rsz()">
<img id="cpnt" src="/icons/gal1/p1.jpg" onClick="sb(1,1)" border=0>
<script type="text/javascript">
<!--
var pc=document.getElementById("cpnt");
zoom(pc.width, pc.heigth);
//-->
</script>
</body>
</html>