2013-06-18 2 views
1

이미지가있는 팝업이 있습니다. 내 이미지 크기를 설정할 수 있는지 알고 싶습니다. 내 팝업을 위해이 스크립트를 만들었습니다.이미지를 팝업으로 크기 조정

function open_win(title, description, src, alt) 
{ 
    var img = document.createElement("img"); 
    img.src = src; 
    img.alt = alt; 

    myWindow = window.open('', '', 'width=300, height=300, left=700, top=400') 
    myWindow.document.write("<div class='description'> <img src=" + src + " alt=" + alt + " >") 
    myWindow.document.write("<h4>" + title + "</h4>") 
    myWindow.document.write("<p>" + description + "</p></div>") 

    document.body.appendChild(img) 

    myWindow.focus() 
} 

내 사진이 1185x785가되고 싶습니다. 나는 그 일을하는 방법을 모색했지만, 창 크기를 조정할 때 답을 얻었지만 필요하지는 않습니다. 난 그냥 내 이미지의 크기를 조정하고 싶다. 감사! 이 시도했지만 작동하지 않습니다 :

img.style.width='1185px'; 
img.style.height='785px'; 

답변

1

나는 답을 발견! 이 하나

myWindow.document.write("<div class='description'> <img src=" + src + " alt=" + alt + " width=1185 height=785 >") 

myWindow.document.write("<div class='description'> <img src=" + src + " alt=" + alt + " >") 

: 난 그냥이 줄을 변경해야

관련 문제