R
Randell D.
HELP!
Its taken me ages - I'm a newbie and I've compiled bits of code that I've
read in this newsgroup over time to create one of my most intricate
functions to date...
Basically, the script gets called with a single arguement (full path to an
image). The image is supposed to be downloaded to the cache, and when
complete, a new window opened that is slightly larger insize then the images
dimensions... The new window will contain the image, and the new window will
be in the middle of the screen...
Nice?
Well... It almost works... in Mozilla, after a handful of refreshes, the
script works as above... In IE6 though, nothing... no errors... no window..
nothing... During development, I used the Javascript Console to help me and
I believe the problem is where I use the window.setTimeout function.
Specifically, when I try to call the parent function and pass it the image
path, and the use (or overuse?) of quotes...
Can someone help straighten it out as I am proud of it and I think somebody
out there (other than myself) will actually get some use out of this once
its fully working...
The script is below... along with my HTML <img onClick> tag (with newlines
to make it more readable)....
<script type='text/javascript'>
function imageInNewWindow(imgsrc)
{ // Display the image in a new window that is centered in the middle of the
screen
var oImg = new Image();
oImg.src = imgsrc;
var newWinWidth=(oImg.width*1.09);
var newWinHeight=(oImg.height*1.09);
var winX = (screen.width-oImg.width)/2;
var winY = (screen.height-oImg.height)/2;
if (oImg.complete) {
window.open(imgsrc,"myWindowName");
// I remarked the following two lines in case it might be part of the
problem - I think its fine though...
//,"height="+newWinHeight+",width="+newWinWidth+",top="+winY+",left="+winX+"
");
//,menubar=no,resizeable=no,toolbar=0,location=0,scrollbars=0");
return true;
}
window.setTimeout("imageInNewWindow('"+imgsrc+"')", 1000);
return true;
}
</script>
<img src=http://www.myDomain.com/tKnitting-35.jpg
border=0
onClick="imageInNewWindow('http://www.myDomain.com/tKnitting-35.jpg');
return false">
Its taken me ages - I'm a newbie and I've compiled bits of code that I've
read in this newsgroup over time to create one of my most intricate
functions to date...
Basically, the script gets called with a single arguement (full path to an
image). The image is supposed to be downloaded to the cache, and when
complete, a new window opened that is slightly larger insize then the images
dimensions... The new window will contain the image, and the new window will
be in the middle of the screen...
Nice?
Well... It almost works... in Mozilla, after a handful of refreshes, the
script works as above... In IE6 though, nothing... no errors... no window..
nothing... During development, I used the Javascript Console to help me and
I believe the problem is where I use the window.setTimeout function.
Specifically, when I try to call the parent function and pass it the image
path, and the use (or overuse?) of quotes...
Can someone help straighten it out as I am proud of it and I think somebody
out there (other than myself) will actually get some use out of this once
its fully working...
The script is below... along with my HTML <img onClick> tag (with newlines
to make it more readable)....
<script type='text/javascript'>
function imageInNewWindow(imgsrc)
{ // Display the image in a new window that is centered in the middle of the
screen
var oImg = new Image();
oImg.src = imgsrc;
var newWinWidth=(oImg.width*1.09);
var newWinHeight=(oImg.height*1.09);
var winX = (screen.width-oImg.width)/2;
var winY = (screen.height-oImg.height)/2;
if (oImg.complete) {
window.open(imgsrc,"myWindowName");
// I remarked the following two lines in case it might be part of the
problem - I think its fine though...
//,"height="+newWinHeight+",width="+newWinWidth+",top="+winY+",left="+winX+"
");
//,menubar=no,resizeable=no,toolbar=0,location=0,scrollbars=0");
return true;
}
window.setTimeout("imageInNewWindow('"+imgsrc+"')", 1000);
return true;
}
</script>
<img src=http://www.myDomain.com/tKnitting-35.jpg
border=0
onClick="imageInNewWindow('http://www.myDomain.com/tKnitting-35.jpg');
return false">