图片缩放(放大的时候另开一个窗口)

HTML部分:

1 <img width="300" id="b" src="1.png" alt="">

JAVASCRIPT部分:

var img = document.getElementById("b");
img.onclick = function(){
    try{
        imgPopup.close();
    }catch(e){

    }
    imgPopup=window.open('','','')
    imgPopup.document.write('<script>document.onclick=function(){ close();}<\/script>'); 
    imgPopup.document.write('<img src="'+this.src+'"/>','<style>body{margin:0;padding:0;border:0;}<\/style>'); 
    imgPopup.focus(); 
    imgPopup.document.close(); 
}

 

posted @ 2020-04-27 11:01  傅丹辰cds  阅读(201)  评论(0)    收藏  举报