웹마스터 팁
page_full_width">
갤러리스킨에 쓰면 좋을 것 같은 미리보기(수정2)
2003.01.06 04:14
<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... 이라는 메시지를 출력하도록 했습니다.
<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... 이라는 메시지를 출력하도록 했습니다.
댓글 10
-
Z∈∩Ⅰ§∈
2003.01.06 08:25
감사 -
BIRDY™
2003.01.06 20:56
정말 좋군요...
그런데 저만 그런건지는 모르겠지만
이미지가 완전히 다 보이지가 않는군요.
그러니까 이미지 크기랑 창의 크기가 조금
차이가 나는듯해요...맞나??? ^^;
이와 비슷한 어떤 소스에서는
resizeBy를 사용해서 어쩌구저쩌구
이미지와 창과의 크기를 더했다 뺐다...
암튼 그건 이미지에 딱맞게 창 크기도 설정된다는...
암튼 요것두 좋습니다.~ ^^ -
한상욱
2003.01.06 22:50
행복한고니님.. 감사..
실력과 다른사람에 대한 배려를 겸비한 분을 만나는것은 어려운일이지요..
행복한고니님과 같은 분을 만날수 있어서 nzeo는 너무도 좋은곳이네요..
늦은시간 도와주셨는데...
끝까지 못봤네요.. -
행복한고니
2003.01.07 04:08
차이가 생겨요...? -_-;; 다시 손봐야겠네...
그리고 때때로 이미지가 다 열리지도 않고 그냥 멈춰버리는 경우도 있어서리...
흠... 전면 수정을 한번해봐야 할 것 같다는...
그리고 한상욱님...
허접때기를 이뿌게 봐줘서 너무 감사합니다. ㅠ_ㅠ -
한상욱
2003.01.07 22:15
행복한고니님...
새창여는 스크립트에서요,,,
openwin("imgwin.html?http://image.com/images/test.gif") <-- 이건 에러나던데요.. -_-;;
openwin(' imgwin.html?http://image.com/images/test.gif ')" <-- 요렇게 하니까.. 중앙에서 새창이 안뜨고
왼쪽 구석에서.. 열리네요..
위에 <html> ~ </html> 까지 저장해서 imgwin.htm 파일 만들고..
썸네일 이미지 있는 페이지에 <head></head>사이에
<script>
function openwin(url){
window.open(url,"previewWin","width=100,height=100,top=1,left=1,toolbar=no,resizable=no,status=no,scrollbar=no");
}
</script>
요거 붙여넣고
<a href="javascript:openwin('imgwin.html?http://gallap.com/aa/bb/images/P1010021.jpg')"><IMG src="thumbnails/P1010021.jpg" border="0" alt="P1010021"></A> 이렇게 불렀답니다..
그런데.. 에러가 있는듯,,
한번열리면 잘 열리는 에러가 있어서.. ^^; 지금은 잘열리는지 아닌지 모르겠네요..
하지만 왼쪽구석에서 열리는거는 확실 하답니다.. -
행복한고니
2003.01.07 22:53
*^^* 실수가 있었습니다.
sw 와 sc를 정의해주지 않았네요. -
한상욱
2003.01.08 01:40
행복한고니님 덕분에.. 고심하던 부분이 시원하게 풀렸네요... ^^; 감사합니다.
또 다른 문제로.. 고니님을 잠못들게 할지도 모르는데.. -_-;; 워낙 허덥때기라서.. -
행복한고니
2003.01.08 01:53
^^;; 원래 밤에는 잠을 잘 안자니... (폐...폐인... -_-;;) 상관없습니다. 훗~ -
한상욱
2003.01.09 02:14
마지막까지.. 감동시키시는군요....
Loading... -
오즈
2003.01.09 16:46
멋진 팁이네요... 정상적으루 잘 나옵니다 ^^*
저번팁은... 저는 잘 보였는데, 다른분들이 안보인다구 하더라구요...
히히... 어쨌든 지금꺼 너므너므 잘되구.. 잘 사용할께요... 추천 꾹~