웹마스터 팁

<html>
<script>
var imgTmp = new Image();
ns = (document.getElementById && !document.all)?1:0;

function g_resizeWin(){
        var imgsrc, url = document.location.href+"";

        if(url.indexOf('?') > 0){
                imgsrc = url.substring(url.indexOf('?')+1,url.length);
                imgTmp.src = imgsrc;
                imgobj.src= imgsrc;
        }else{
                alert("No Image or incorrect URL");
                self.close();
        }

        imgTmp.onload = new Function("resize()");
}
function resize(){
        var cw = document.body.clientWidth;
        var ch = document.body.clientHeight;
        var sw = screen.width;
        var sh = screen.height;
        var hide = (ns)?document.getElementById("hide"):document.all["hide"];
        var show = (ns)?document.getElementById("show"):document.all["show"];

        hide.style.display = "none";
        show.style.display = "block";

        window.moveTo((sw - imgTmp.width)/2, (sh - imgTmp.height)/2);
        if(imgTmp.width==cw && imgTmp.height==ch) return true;
        window.resizeBy(imgTmp.width-cw, imgTmp.height-ch);
}
</script>
<title>미리보기</title>
<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 onLoad="g_resizeWin()">
<div id=hide>
        <table width=100% height=100%>
                <tr><td align=center style="font-size:9pt">Loading...</td></tr>
        </table>
</div>
<div id=show style="display:none"><a href='javascript:self.close()'><img name=imgobj border=0></a></div>
</body>
</html>

위의 것이 소스구요... 사실 수정할 것은 없습니다. 그냥 새창을 띄워주면서 뒤쪽에 ?그림URL 과 같이 해주시면 됩니다. 예를 들어 위 소스를 저장한 파일이 imgwin.html 이라고 하면 새창을 띄울때 URL에

imgwin.html?http://image.com/images/test.gif 와 같은 식으로 적어주시면 됩니다.

여타 프로그래밍 언어없이 자바스크립트 만으로 구현할 수 있어서 괜찮을 겁니다. -_-;;
혹시 필요할지 몰라서 새창여는 스크립트도 첨부해드립니다.
사용은 openwin("imgwin.html?http://image.com/images/test.gif") 과 같은 식으로 하시면 됩니다.

<script>
function openwin(url){
        window.open(url,"previewWin",'width='+300+',height='+200+',top='+(screen.height-200)/2+',left='+(screen.width-300)/2+',toolbar=no,resizable=no,status=no,scrollbar=no');
}
</script>

P.S//이 늦은 밤 함께 테스트하다가 완성을 못보고 주무신... -_-;; 한상욱님(gallap)에게 감사드립니다.

## 수정내용(2003-01-07)
1. image 객체의 onLoad 이벤트를 사용했습니다.
2. resize() 함수를 한번만 실행하도록 했습니다.
3. 내친김에 화면 딱 중간에 창이 오도록 바꾸었습니다.

## 수정내용(2003-01-08)
1. 일부 이미지의 사이즈 함수가 맞지 않는다는 얘기가 있어서 수정했습니다.
2. 이미지 로딩전에 Loading... 이라는 메시지를 출력하도록 했습니다.
제목 글쓴이 날짜
ie60이상버전의 개인정보기능으로 인한 서비스문제 [2] 날파리 2003.05.21
[간단팁] 윈도우즈 2003 에서 mysql 사용할때.. [5] 오종선 2003.05.22
[진자 유용한] www 자동으로 붙여주기 [6] Dopesoul 2003.05.24
APM_Setup4 에서 에러페이지 띄우기 [2] RedEye(kaist) 2003.05.28
아파치 보안취약점 관련 버전 업데이트 DearMai 2003.05.30
iis + php + mysql 강좌 (윈도우설치) [5] 이성헌 2003.06.01
iis + php + mysql 보충설명. [2] 이성헌 2003.06.01
아파치 버츄얼웹서버에서 웹로그 분석툴 : Webalizer 설치 [2] [1] 정인배 2003.06.02
네임(DNS) 서버 named.conf 설정 하기 정인배 2003.06.02
아파치 : Name-based Virtual Host 사용하기 정인배 2003.06.02
아파치 : IP-based Virtual Host 사용하기 정인배 2003.06.02
Windows Media 서비스에 대한 ISAPI 확장 결함 DearMai 2003.06.03
apache + php + mysql (window 설치) 이성헌 2003.06.05
mysql 강좌 .. 요약본 [4] 이성헌 2003.06.05
php 와 mysql 을 이용한 웹인증..(윈도우에서) 이성헌 2003.06.05
apache 서버에서 apache 인증 (윈도우에서 apm 설치후) 이성헌 2003.06.05
apache 서버에서 디렉토리 보기 방지. [5] 이성헌 2003.06.08
윈98에서 Apache+iASP+Tomcat4.x+Mysql+PHP ...사용하기 [5] 한희진 2003.06.11
webalizer 윈도우+아파치에서 돌려보기 [3] [1] HuHu^^; 2003.06.12
극심한 시스템 파괴시 재해복구 Process [7] Dopesoul 2003.06.14