Open image in new window

后端 未结 7 976
执笔经年
执笔经年 2020-11-28 14:34

How can I open an image in a new window by using its id?

function swipe()
{   
    var largeImage = document.getElementById(\'largeImage\');
            


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 15:07

    Try with the following function:

    function newTabImage() {
        var image = new Image();
        image.src = $('#idimage').attr('src');
    
        var w = window.open("",'_blank');
        w.document.write(image.outerHTML);
        w.document.close(); 
    }
    

    Call with this HTML code:

    
    

提交回复
热议问题