이미지 싸이즈대로 새창띄우고 클릭하면 창닫기
<head>와</head>사이에
<script language="javascript">
function view(what) {
var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width=10,height=10');
imgwin.focus();
imgwin.document.open();
imgwin.document.write("<html>\n");
imgwin.document.write("<head>\n");
imgwin.document.write("<title>**</title>\n");
imgwin.document.write("<sc"+"ript>\n");
imgwin.document.write("function resize() {\n");
imgwin.document.write("pic = document.il;\n");
//imgwin.document.write("alert(eval(pic).height);\n");
imgwin.document.write("if (eval(pic).height) { var name = navigator.appName\n");
imgwin.document.write(" if (name == 'Microsoft Internet Explorer') { myHeight = eval(pic).height + 40; myWidth = eval(pic).width + 12;\n");
imgwin.document.write(" } else { myHeight = eval(pic).height + 9; myWidth = eval(pic).width; }\n");
imgwin.document.write(" clearTimeout();\n");
imgwin.document.write(" var height = screen.height;\n");
imgwin.document.write(" var width = screen.width;\n");
imgwin.document.write(" var leftpos = width / 2 - myWidth / 2;\n");
imgwin.document.write(" var toppos = height / 2 - myHeight / 2; \n");
imgwin.document.write(" self.moveTo(leftpos, toppos);\n");
imgwin.document.write(" self.resizeTo(myWidth, myHeight);\n");
imgwin.document.write("}else setTimeOut(resize(), 100);}\n");
imgwin.document.write("</sc"+"ript>\n");
imgwin.document.write("</head>\n");
imgwin.document.write('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">\n');
imgwin.document.write("<img border=0 src="+what+" xwidth=100 xheight=9 name=il onload='resize();'>\n");
imgwin.document.write("</body>\n");
imgwin.document.close();
}
</script>
<body>와</body>사이에
<a href="javascript:view('이미지주소')">꾸욱 눌러요!</a> ---글씨링크 일때
<a href="javascript:view('이미지주소')"><img src="이미지주소" width="80" height="80"></a>---그림링크 일때
새창 열린 이미지를 클릭하면 창이 닫히게하는 소스로 하려면
끝에서 위로 네번째줄에
("<img border=0 src="+what+" xwidth=100 xheight=9 name=il onload='resize();'>\n"); 이 앞에
("<a href=# onclick=window.close() onfocus=this.blur()>을 추가해 주고
onload='resize();'> 이것 뒤에 </a>를 넣어 줍니다.
정리한 소스를 적어보면
imgwin.document.write("<a href=# onclick=window.close() onfocus=this.blur()><img border=0 src="+what+" xwidth=100 xheight=9 name=il onload='resize();'></a>");
'컴퓨터-유용한팁 > 스크립트' 카테고리의 다른 글
상태바에 글씨 써졌다,지워졌다 (0) | 2015.09.07 |
---|---|
플래시를 랜덤하게 나타내기 (0) | 2015.09.07 |
아이프레임 싸이즈 자동조절 (0) | 2015.09.07 |
팝업창 2개 띄우기 (0) | 2015.09.07 |
프레임 소스보기 막기 (0) | 2015.09.07 |