이미지가 있습니다..
이거를 클릭하면 새창으로 이미지만 뜨고 한번 더 클릭하면 닫히게 하려면 어떻게 해야 할지...
궁금합니다. 자바스크립트로 할거 같은데..혹시 소스 아시면 소개 좀 부탁드려요..
답변 1개 / 댓글 1개
채택된 답변
+20 포인트
2016-08-05 (금) 16:47:21
예를 들어 320x240 크기의 test.jpg 이미지를 새창으로 띄우고 클릭하면 닫히게 할려면
Copy
<img src="./images/test.jpg" onclick="image_window('./images/test.jpg','320','240');" style='cursor:hand;border:0;'> <script> function image_window(img,w,h) { var img = img; var winl = (screen.width-w)/2; var wint = (screen.height-h)/3; if (w >= screen.width) { winl = 0; h = (parseInt)(w * (h / w)); } if (h >= screen.height) { wint = 0; w = (parseInt)(h * (w / h)); } var settings; settings ='width='+w+','; settings +='height='+h+','; settings +='top='+wint+','; settings +='left='+winl+','; settings +='scrollbars=no,'; settings +='resizable=yes,'; settings +='status=no'; win=window.open("","image_window",settings); win.document.open(); win.document.write ("<html><head> \n<meta http-equiv='imagetoolbar' CONTENT='no'> \n<meta http-equiv='content-type' content='text/html; charset=euc-kr'>\n"); var size = "이미지 사이즈 : "+w+" x "+h; win.document.write ("<title>"+size+"</title> \n"); var click = "onclick='window.close();' style='cursor:pointer' title=' "+size+" \n\n 클릭하면 닫혀요. '"; win.document.write ("<style>.dragme{position:relative;}</style> \n"); win.document.write ("</head> \n\n"); win.document.write ("<body leftmargin=0 topmargin=0 bgcolor=#dddddd style='cursor:arrow;'> \n"); win.document.write ("<table width=100% height=100% cellpadding=0 cellspacing=0><tr><td align=center valign=middle><img src='"+img+"' width='"+w+"' height='"+h+"' border=0 class='dragme' "+click+"></td></tr></table>"); win.document.write ("</body></html>"); win.document.close(); }</script>
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.