1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > js实现点击查看大图功能

js实现点击查看大图功能

时间:2019-03-18 20:52:18

相关推荐

js实现点击查看大图功能

使用layui的弹窗实现点击查看大图功能

function getImage(url, callback){let img = new Image();img.src = url;if(plete){callback(img.width, img.height);}else{img.onload = function(){callback(img.width, img.height);}}}function showBigImage(url) {getImage(url, function(w, h){let widht = $(window).width() * 0.9;let height = $(window).height() * 0.9;if (w > h) {widht = widht > w ? w : widht;height = widht * h/w;} else {height = height > h ? h : height;widht = height * w/h;}layer.open({type: 1,title: false,closeBtn: 0,shadeClose: true,area: [widht + 'px', height + 'px'],content: '<img src="' + url + '" οnclick="window.open(this.src)" style="max-width: ' + widht + 'px;max-height: ' + height + 'px;cursor:pointer;"/>'});});}// 使用$(document).on('click', "table img,form img", function () {showBigImage($(this).attr("src"));});

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。