//이미지 크기에 맞는 팝업창 띄우기
var imgObj = new Image();
function ShowImgWin(imgName)
{
imgObj.src = imgName;
setTimeout("CreateImgWin(imgObj)", 100);
}
function CreateImgWin(imgObj)
{
if (! imgObj.complete)
{
setTimeout("createImgWin(imgObj)", 100);
return;
}
imageWin = window.open("", "imageWin", "width=" + imgObj.width + ",height=" + imgObj.height);
imageWin.document.write("<html><center><body style='margin:0'>");
imageWin.document.write("<table width='100%' height='100%' onclick='self.close();' style='cursor:pointer'>");
imageWin.document.write("<tr><td width='100%' height='100%' align='center' valign='middle'>");
imageWin.document.write("<img src='" + imgObj.src + "' border=0></td></tr></table>");
imageWin.document.write("</body></center><html>");
imageWin.document.title = imgObj.src;
}
실행예 > ShowImgWin("http://~/test.gif");
javascript 로 이미지 크기에 맞는 팝업창 띄우기
2009. 11. 16. 16:44
반응형