본문 바로가기

Front end/JS (JavaScript)

자바스크립트(JavaScript) 이미지 크기에 맞게 팝업창 띄우기(새창열기), image size popup

728x90
winOpen('이미지경로'.png')

function winOpen(img){ 
    photo = new Image(); 
    photo.src = img; 
    processTime(img); 
} 
function processTime(img){ 
    if(photo.width == 0 && photo.height == 0){ 
        setTimeout("processTime('"+img+"')",30); 
    } 
    else{ 
        let wt = photo.width+20; 
        let ht = photo.height+20; 
        window.open(img,"","width="+ wt +",height="+ ht); 
        console.log("width = "+wt + "height = "+ht)
    } 
} 
728x90