인터넷정보

문서 없이 자동으로 이미지 크기에 맞게 새창 및 .....

알 수 없는 사용자 2007. 10. 18. 13:47

http://oxtag.com/html/ex/popup/img_win/img_win.html

문서 없이 자동으로 이미지 크기에 맞게 새창으로 그림을 띄웁니다.
전체화면으로 열 수 있는 F11 키 제어 했구요.
마우스도 감지 못하게 했습니다.
그리고, 화면 중앙에 열리게 했구요.
소스는 상단의 미리보기를....



function view(what) { 
var imgwin = window.open('','','scrollbars=no,status=no,toolbar=no,resizable=1,location=no,menu=no,width=10,height=10'); 
imgwin.document.open(); 
imgwin.document.write("<html>\n"); 
imgwin.document.write("<head>\n"); 
imgwin.document.write("<title>♡ 카멜롯™의 소스천국 태그피아 ♡</title>\n");
imgwin.document.write("<META HTTP-EQUIV='imagetoolbar' CONTENT='no'>\n"); // IE 이미지 툴바 제거
imgwin.document.write("<script>\n");
imgwin.document.write(" document.onkeydown=KeyEventHandle;\n");   // F11 키 제어
imgwin.document.write(" document.onkeyup=KeyEventHandle;\n");
imgwin.document.write(" document.onkeydown=KeyEventHandle;\n");
imgwin.document.write(" document.onkeyup=KeyEventHandle;\n");
imgwin.document.write(" function KeyEventHandle()\n");
imgwin.document.write(" {\n");
imgwin.document.write("    if  (event.keyCode == 122)\n");
imgwin.document.write("     { \n");
imgwin.document.write("                 event.keyCode = 0;\n");
imgwin.document.write("                 event.cancelBubble = true;\n");
imgwin.document.write("                 event.returnValue = false;\n");
imgwin.document.write("         alert ('윈도우를 종료합니다');\n");
imgwin.document.write("         self.close();     \n");
imgwin.document.write("    }\n");
imgwin.document.write(" }\n");       // F11 키 제어 끝.
imgwin.document.write("var isNav4, isIE4;\n");
imgwin.document.write("var windowX, windowY;\n");
imgwin.document.write("var bLargeImage = 0;\n");
imgwin.document.write("var x,y;\n");
imgwin.document.write("\n");
imgwin.document.write("if (parseInt(navigator.appVersion.charAt(0)) >= 4)\n");
imgwin.document.write("{\n");
imgwin.document.write("    isNav4 = (navigator.appName == 'Netscape') ? 1 : 0;\n");
imgwin.document.write("    isIE4 = (navigator.appName.indexOf('Microsoft') != -1) ? 1 : 0;\n");
imgwin.document.write("}\n");
imgwin.document.write("\n");
imgwin.document.write("function fitWindowSize()\n");
imgwin.document.write("{\n");
imgwin.document.write("    if (isNav4) {\n");
imgwin.document.write("        window.innerWidth = document.layers[0].document.images[0].width;\n");
imgwin.document.write("        window.innerHeight = document.layers[0].document.images[0].height;\n");
imgwin.document.write("    }\n");
imgwin.document.write("    if (isIE4) {\n");
imgwin.document.write("        window.resizeTo(500, 500);\n");
imgwin.document.write("        width = 500 - (document.body.clientWidth -  document.images[0].width);\n");
imgwin.document.write("        height = 500 - (document.body.clientHeight -  document.images[0].height)\n");
imgwin.document.write("        windowX = (window.screen.width-width)/2;\n");
imgwin.document.write("        windowY = (window.screen.height-height)/2;\n");
imgwin.document.write("        if(width>screen.width){\n");
imgwin.document.write("            width = screen.width;\n");
imgwin.document.write("            windowX = 0;\n");
imgwin.document.write("            bLargeImage = 1;\n");
imgwin.document.write("        }\n");
imgwin.document.write("        if(height>screen.height-50){\n");
imgwin.document.write("            height = screen.height-50;\n");
imgwin.document.write("            windowY = 0;\n");
imgwin.document.write("            bLargeImage = 1;\n");
imgwin.document.write("        }\n");
imgwin.document.write("        x = width/2;\n");
imgwin.document.write("        y = height/2;\n");
imgwin.document.write("        window.moveTo(windowX,windowY);\n");
imgwin.document.write("        window.resizeTo(width, height);\n");
imgwin.document.write("    }\n");
imgwin.document.write("}\n");
imgwin.document.write("function move()\n");
imgwin.document.write("{\n");
imgwin.document.write("    if(bLargeImage)\n");
imgwin.document.write("    window.scroll(window.event.clientX - 50,window.event.clientY -50);\n");
imgwin.document.write("}\n");
imgwin.document.write("</script>");
imgwin.document.write("</head>"); 
imgwin.document.write('<body onLoad="fitWindowSize();" onmousemove="move();" onclick=window.close() topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onkeydown="return false">'); 
imgwin.document.write("<a href='#a' onfocus=this.blur() style='cursor:move'><img border=0 src="+what+" xwidth=100 xheight=9 name=il onload='resize();'></a>"); 
imgwin.document.write("</body>");
imgwin.document.write("</html>"); 
imgwin.document.close(); 

}

반응형