··조회 13,319
[re] 새창뛰우기
><a href={$row[file_name1]} target='_blank'>{$row[s_file_name1]} ({$file_size1}KB)</a>에서 새창뛰우기를 했습니다.
>근데 이미지 크기에 맞춰서 새창으로 뛰우게 하려면 어떻게 해야하나요....
자바스크립트를 쓰면 됩니다.
<SCRIPT LANGUAGE="JavaScript">
<!--
function imgResize(img){
img1= new Image();
img1.src=(img);
imgControll(img);
}
function imgControll(img){
if((img1.width!=0)&&(img1.height!=0)){
viewImage(img);
}
else{
controller="imgControll('"+img+"')";
intervalID=setTimeout(controller,20);
}
}
function viewImage(img){
W=img1.width;
H=img1.height;
O="width="+W+",height="+H;
imgWin=window.open("","",O);
imgWin.document.write("<html><head></head>");
imgWin.document.write("<body topmargin=0 leftmargin=0>");
imgWin.document.write("<img src="+img+" onclick='self.close()'>");
imgWin.document.write("</body></html>");
imgWin.document.close();
}
// -->
</script>
위 소스를 <head> 와 </head> 사이에 넣고 링크는 아래와 같이 걸면 됩니다.
<a href='javascript:imgResize($row[file_name1])' target='_blank'>.....</a>
>근데 이미지 크기에 맞춰서 새창으로 뛰우게 하려면 어떻게 해야하나요....
자바스크립트를 쓰면 됩니다.
<SCRIPT LANGUAGE="JavaScript">
<!--
function imgResize(img){
img1= new Image();
img1.src=(img);
imgControll(img);
}
function imgControll(img){
if((img1.width!=0)&&(img1.height!=0)){
viewImage(img);
}
else{
controller="imgControll('"+img+"')";
intervalID=setTimeout(controller,20);
}
}
function viewImage(img){
W=img1.width;
H=img1.height;
O="width="+W+",height="+H;
imgWin=window.open("","",O);
imgWin.document.write("<html><head></head>");
imgWin.document.write("<body topmargin=0 leftmargin=0>");
imgWin.document.write("<img src="+img+" onclick='self.close()'>");
imgWin.document.write("</body></html>");
imgWin.document.close();
}
// -->
</script>
위 소스를 <head> 와 </head> 사이에 넣고 링크는 아래와 같이 걸면 됩니다.
<a href='javascript:imgResize($row[file_name1])' target='_blank'>.....</a>
댓글 2
앞으로도 질문에 대한 답변 부탁드리겠습니다.