var imgObj;
function checkImg(theURL,winName){
  // 对象是否已创建
  if (typeof(imgObj) == "object"){
    // 是否已取得了图像的高度和宽度
    if ((imgObj.width != 0) && (imgObj.height != 0))
      // 根据取得的图像高度和宽度设置弹出窗口的高度与宽度，并打开该窗口
      // 其中的增量 20 和 30 是设置的窗口边框与图片间的间隔量
      //OpenFullSizeWindow(theURL,winName, ",width=" + (imgObj.width+0) + ",height=" + (imgObj.height+0));
      DynaWindow(theURL,winName,imgObj.width,imgObj.height);
    else
      // 因为通过 Image 对象动态装载图片，不可能立即得到图片的宽度和高度，所以每隔100毫秒重复调用检查
      setTimeout("checkImg('" + theURL + "','" + winName + "')", 100)
  }
}
function ow(theURL) {
winName = "top";
    // 创建图像对象
    imgObj = new Image();
    // 设置图像源
    imgObj.src = theURL;
    // 开始获取图像大小
    checkImg(theURL, winName)
  }

function DynaWindow(url,winName,w,h) {
var disp, sBaseCmd;
  // 弹出窗口外观参数
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - w) / 2;
yposition = (screen.height - h) / 2;
}
  // 弹出窗口外观参数
sBaseCmd= "width=" + w + "," 
+ "height=" + h + "," 
+ "location=0," 
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=0,"
+ "status=0," 
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" + yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE     // 打开窗口
disp = window.open(url,winName,"height=" + h + ",width=" + w + sBaseCmd);
    // 聚焦窗口
disp.focus();
content = '<HTML>';
content += '<TITLE>点击图片关闭窗口</TITLE>';
content += '</HEAD>';
content += '<BODY onBlur="self.close()" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
content += '<img src="'+url+'" height="' + h + '" width="' + w + '" alt="点击关闭" onclick="self.close()">';
content += '</BODY></HTML>';
disp.document.write(content);
disp.document.close();
}

