HTML内使用代码:
<img src="..." alt="..." width="200px" height="200px" class="layui-upload-img" onclick="previewImg(this)">
JS代码部分:
function previewImg(obj) {
var img = new Image();
img.src = obj.src;
var height=img.height,width=img.width;
if(img.height > 600) {
height = '600px';
width=(600/(img.height))*(img.width);
}
var imgHtml = "<img src='" + obj.src + "' height='"+height+"' width='"+width+"' />";
//弹出层
layer.open({
type: 1,
offset: 'auto',
area: [width,'auto'],
shadeClose:true,//点击外围关闭弹窗
scrollbar: false,//不现实滚动条
title: "图片预览", //不显示标题
content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响
cancel: function () {
}
});
}
The End


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)