<html>
<head>
<title>자동으로 이미지 크기에 맞추어 새창열기</title>
<script language="javascript">
<!--
function view(what) {
var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=no,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 + 36; myWidth = eval(pic).width + 10;\n");
imgwin.document.write(" } else { myHeight = eval(pic).height + 36; myWidth = eval(pic).width + 10; }\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.write("</html>\n");
imgwin.document.close();
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<!-- 오픈창으로 나타낼 이미지의 경로지정 //-->
<a href="javascript:view('image_001.jpg')">Image View [1]</a> | <a href="javascript:view('image_002.jpg')">Image View [2]</a>
</body>
</html>
<head>
<title>자동으로 이미지 크기에 맞추어 새창열기</title>
<script language="javascript">
<!--
function view(what) {
var imgwin = window.open("",'WIN','scrollbars=no,status=no,toolbar=no,resizable=no,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 + 36; myWidth = eval(pic).width + 10;\n");
imgwin.document.write(" } else { myHeight = eval(pic).height + 36; myWidth = eval(pic).width + 10; }\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.write("</html>\n");
imgwin.document.close();
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF">
<!-- 오픈창으로 나타낼 이미지의 경로지정 //-->
<a href="javascript:view('image_001.jpg')">Image View [1]</a> | <a href="javascript:view('image_002.jpg')">Image View [2]</a>
</body>
</html>
'Web > Javascript' 카테고리의 다른 글
상태표시줄에 URL 감추기 (0) | 2013.09.26 |
---|---|
자동북마크 기능 (0) | 2013.09.26 |
미디어플레이어 '시작/정지' 버튼만들기 (0) | 2013.09.26 |
내용을 자동으로 스크롤 시키기 (0) | 2013.09.26 |
프린트 (0) | 2013.09.26 |