링크에 마우스를 대면 이미지가 확대 및 욱소 되는 스크립트 입니다.
쇼핑몰 등에서 상품 이미지를 보여줄때 사용하면 좋을 것 같습니다
<!---- [1단계] 아래의 스크립트를 HEAD 부분에 복사 해 넣으세요 ----->
<script language="JavaScript1.2">
var zoomfactor=0.05 // 스케일을 설정 하세요(0.05=5%)
function zoomhelper(){
if (parseInt(whatcache.style.width)>10&&parseInt(whatcache.style.height)>10){
whatcache.style.width=parseInt(whatcache.style.width)+parseInt(whatcache.style.width)*zoomfactor*prefix
whatcache.style.height=parseInt(whatcache.style.height)+parseInt(whatcache.style.height)*zoomfactor*prefix
}
}
function zoom(originalW, originalH, what, state){
if (!document.all&&!document.getElementById)
return
whatcache=eval("document.images."+what)
prefix=(state=="in")? 1 : -1
if (whatcache.style.width==""||state=="restore"){
whatcache.style.width=originalW
whatcache.style.height=originalH
if (state=="restore")
return
}
else{
zoomhelper()
}
beginzoom=setInterval("zoomhelper()",100)
}
function clearzoom(){
if (window.beginzoom)
clearInterval(beginzoom)
}
</script>
<!-------------- 여기까지 ---------------->
</head>
<body>
<!---- [2단계] BODY 부분에 아래와 같은 방법으로 태그와 코드를 복사 해 넣으세요 --->
<!-- onmouseover="zoom(가로,세로,'이미지_name','in(out)') 의 형식으로 함수의 인자를 설정 하세요-->
<a href="#" onmouseover="zoom(200,200,'myimage','in')" onmouseout="clearzoom()">확대</a> |
<a href="#" onmouseover="zoom(200,200,'myimage','restore')">표준</a> |
<a href="#" onmouseover="zoom(200,200,'myimage','out')" onmouseout="clearzoom()">축소</a>
<br><br>
<div style="position:relative;width:200;height:200">
<div style="position:absolute">
<img name="myimage" src="../c1.jpg"><!-- 여기에 사용할 이미지가 들어갑니다--->
</div></div>
<!-------------- 여기까지 ---------------->
</body>
</html>