그림이 새창으로 뜨면 위에 하얀 부분을 클릭한 채로 드래그 하면 움직임
<html>

<head>

<title>이미지 갤러리 만들기 <2></title>

<script language="JavaScript">
<!--
var ie=document.all
var ns=document.layers
var ns6=document.getElementById&&!document.all

function enlarge(which,e){

if (ie||ns6){
crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
if (crossobj.style.visibility=="hidden"){
crossobj.style.left=ns6? pageXOffset+e.clientX : document.body.scrollLeft+event.clientX
crossobj.style.top=ns6? pageYOffset+e.clientY : document.body.scrollTop+event.clientY

crossobj.innerHTML='<div id=drag align=right style=background:#FFFFFF><img onClick=closepreview() src=img/close.gif style=cursor:hand></div><img src="'+which+'">'

crossobj.style.visibility="visible"
}
else
crossobj.style.visibility="hidden"
return false
}

else if (document.layers){
if (document.showimage.visibility=="hide"){
document.showimage.document.write('<a href="#" onMouseover="drag_dropns(showimage)"><img src="'+which+'" border=0></a>')
document.showimage.document.close()
document.showimage.left=e.x
document.showimage.top=e.y
document.showimage.visibility="show"
}
else
document.showimage.visibility="hide"
return false
}

else
return true
}

function closepreview(){
crossobj.style.visibility="hidden"
}

//-->
</script>

<script language="JavaScript1.2">
<!--

var nsx,nsy,nstemp

function drag_dropns(name){
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
function stopns(){

temp.releaseEvents(Event.MOUSEMOVE)
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx
crossobj.style.top=tempy+e.clientY-offsety
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="drag"||ns6&&e.target.id=="drag"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
//-->
</script>

</head>

<body>

<table align="center" cellpadding="0" cellspacing="0" width="520"><tr>

<td width="130" align="center" valign="middle">    

<span onClick="return enlarge('img/img1.gif',event)" style="cursor:hand"><img src="img/img1.gif" width="120" height="146"></span>        

<td width="130" align="center" valign="middle">          

<span onClick="return enlarge('img/img2.gif',event)" style="cursor:hand"><img src="img/img2.gif" width="120" height="146"></span>        

<td width="130" align="center" valign="middle">          

<span onClick="return enlarge('img/img3.gif',event)" style="cursor:hand"><img src="img/img3.gif" width="120" height="146"></span>        

<td width="130" align="center" valign="middle">          

<span onClick="return enlarge('img/img4.gif',event)" style="cursor:hand"><img src="img/img4.gif" width="120" height="146"></span>

</tr></table>

<div id="showimage" style="position:absolute; visibility:hidden; border:1 solid #000000"></div>
</body>
</html>

─ 설명 ─

<head>와 </head>사이에
왼쪽 소스보기에 자바스크립트 소스를 집어 넣는다.

자바스크립트 소스 중에 초록색르로 된

crossobj.innerHTML='<div id=drag align=right style=background:#FFFFFF><img onClick=closepreview() src=img/close.gif style=cursor:hand></div><img src="'+which+'">

부분에서
align=right은 닫기 버튼을 정열을 시키는 부분
style=background:#FFFFFF 은 닫기 보튼 왼쪽에 있는
부분으로 드래그하면 이미지가 움직일 수 있도록 하는 부분이다
src=img/close.gif  닫기 버튼 이미지<body>와 </body>사이에 이미지가 들어갈 부분에
아래의 소스를 넣는다

<span onClick="return enlarge('img/img1.gif',event)" style="cursor:hand"><img src="이미지주소" width="가로크기" height="세로크기"></span>



<body>와 </body>사이에 아무곳에나
아래의 소스를 넣는다.

<div id="showimage" style="position:absolute; visibility:hidden; border:1 solid #000000"></div>

border:1 solid #000000" - 원본이미지를 보여줄 때 테두리 두께와 색
Posted by 알 수 없는 사용자
,