R
ryanoasis
Have thumbnail images and clicking on image opens new window with a
different image (larger version) but each large version is a different
size and I dont want to hardcode the size of the new window to match
each larger version.
I hope that made sense.
This code works fine in IE but I have to click the thumbnail twice in
Firefox for the new window to be properly sized and three times in
safari for it to be proper size. However if I have an alert('');
before opening the new window it will size fine.
This code is definitely inefficient (because I was trying different
things to try to make it work).
function popupCenter1(strImage) {
var strImageTitleTemp = new Image();
strImageTitleTemp.lowsrc = strImage.src.replace("sm",
"").replace("SM", "").toString();
strImageTitleTemp.src = strImage.src.replace("sm", "").replace("SM",
"").toString();
var h = strImageTitleTemp.height;
var w = strImageTitleTemp.width;
var strImageTitle = new Image(w,h);
strImageTitle.src = strImageTitleTemp.src;
var strSize = "";
if(strImageTitleTemp.width < 300) {
strSize = "style='font-size: 8pt'";
}
var cW = (screen.availWidth / 2) - (w / 2);
var cH = (screen.availHeight / 2) - (h / 2);
var page="<html><head><title>Image: " + strImageTitle.alt + "</
title><link rel='stylesheet' href='css/styles.css' type='text/css'></
head><body style='background-image: none;' leftmargin='0'
rightmargin='0' topmargin='0' bottommargin='0'><div
align='center'><table border='0' cellpadding='0' cellspacing='0'
width='100%'><tr><td class='header'><img src='images/site/
left_corner_top.gif' align='top'></td><th align='left' class='header'"
+ strSize + ">Image: " + w + ' X ' + h + "</th><td class='header'
align='right'><img src='images/site/right_corner_top.gif'
align='top'></td></tr><tr><th colspan='3'><img src='" +
strImageTitle.src + "'></tr><tr><th align='left' class='header'><img
src='images/site/left_corner_bottom.gif' align='top'></th><td
class='header' " + strSize + "><a style='color: #E3E3E3;'
href='javascript:window.close();'>Close Window</a></td><td
class='header' align='right'><img src='images/site/
right_corner_bottom.gif' align='top'></td></tr></table></div></body></
html>";
alert(''); //
<-------------------------------------------------------------- Having
this allows FF to have window correct size somehow
var msgWindow = window.open('','','Width=' + (w) + ',Height=' + (h
+ 60) + ',left='+cW+',top='+cH
+'toolbar=no,menubar=no,location=no,directories=no,status=no,scrollbars=auto,resizable=no,copyhistory=no');
msgWindow.document.clear();
msgWindow.document.open();
msgWindow.document.write(page);
msgWindow.document.close();
}
Hope this formats okay.. I don't know how to do the formatting on
here. something like
different image (larger version) but each large version is a different
size and I dont want to hardcode the size of the new window to match
each larger version.
I hope that made sense.
This code works fine in IE but I have to click the thumbnail twice in
Firefox for the new window to be properly sized and three times in
safari for it to be proper size. However if I have an alert('');
before opening the new window it will size fine.
This code is definitely inefficient (because I was trying different
things to try to make it work).
function popupCenter1(strImage) {
var strImageTitleTemp = new Image();
strImageTitleTemp.lowsrc = strImage.src.replace("sm",
"").replace("SM", "").toString();
strImageTitleTemp.src = strImage.src.replace("sm", "").replace("SM",
"").toString();
var h = strImageTitleTemp.height;
var w = strImageTitleTemp.width;
var strImageTitle = new Image(w,h);
strImageTitle.src = strImageTitleTemp.src;
var strSize = "";
if(strImageTitleTemp.width < 300) {
strSize = "style='font-size: 8pt'";
}
var cW = (screen.availWidth / 2) - (w / 2);
var cH = (screen.availHeight / 2) - (h / 2);
var page="<html><head><title>Image: " + strImageTitle.alt + "</
title><link rel='stylesheet' href='css/styles.css' type='text/css'></
head><body style='background-image: none;' leftmargin='0'
rightmargin='0' topmargin='0' bottommargin='0'><div
align='center'><table border='0' cellpadding='0' cellspacing='0'
width='100%'><tr><td class='header'><img src='images/site/
left_corner_top.gif' align='top'></td><th align='left' class='header'"
+ strSize + ">Image: " + w + ' X ' + h + "</th><td class='header'
align='right'><img src='images/site/right_corner_top.gif'
align='top'></td></tr><tr><th colspan='3'><img src='" +
strImageTitle.src + "'></tr><tr><th align='left' class='header'><img
src='images/site/left_corner_bottom.gif' align='top'></th><td
class='header' " + strSize + "><a style='color: #E3E3E3;'
href='javascript:window.close();'>Close Window</a></td><td
class='header' align='right'><img src='images/site/
right_corner_bottom.gif' align='top'></td></tr></table></div></body></
html>";
alert(''); //
<-------------------------------------------------------------- Having
this allows FF to have window correct size somehow
var msgWindow = window.open('','','Width=' + (w) + ',Height=' + (h
+ 60) + ',left='+cW+',top='+cH
+'toolbar=no,menubar=no,location=no,directories=no,status=no,scrollbars=auto,resizable=no,copyhistory=no');
msgWindow.document.clear();
msgWindow.document.open();
msgWindow.document.write(page);
msgWindow.document.close();
}
Hope this formats okay.. I don't know how to do the formatting on
here. something like
Code:
?
Thanks