页面点击预览按钮弹出图片窗口

jsp:
<script type="text/javascript" src="${ctx }/resources/javascript/imageView.js"></script>
...
<input type="button" value="点击预览" onclick="imageView('${goodsImg.directory }/${goodsImg.picture }');" />

js:
function imageView(path){
    var random = parseInt(Math.random()*10000+1);
    $.ajax({
        url : jsPath + '/business/system/getImageInfo.do',
        type : "POST",
        dataType : "json",
        data : {path:path},
        success : function(data, textStatus) {
            path = path+"?random="+random;
            var width = 0;
            var height = 0;
            if(data != null && data != ''){
                width = data.width;
                  height = data.height;
            }
            if(width == 0 || height==0){
                top.Dialog.alert("\u56fe\u7247\u4e0d\u5b58\u5728!",null,250,80,null);
            }else{
                top.Dialog.open({
                    InnerHtml: "<img src='"+jsPath+"/"+path+"' width='"+width+"' height='"+height+"' />",
                      Title:"\u56fe\u7247\u9884\u89c8",
                      Width:width,
                     Height:height
                });
            }
        }
    });
}

你可能感兴趣的:(页面点击预览按钮弹出图片窗口)