본문 바로가기

카테고리 없음

[자바스크립트] [이미지] 클릭하면 보더가 생기면서 이미지 보여짐 <닫기> 누르면 사라짐

<head>와 </head>부분에 넣어줍니다.
*****************************************
<script language="JavaScript">
function aplay() {
sizeismax=0;

tempwidth=a.style.pixelWidth;
tempwidth+=16;
if(tempwidth>178) { //사진 가로크기
  a.style.pixelWidth=178; //사진 가로크기
  sizeismax++;
}
else a.style.pixelWidth=tempwidth;

tempheight=a.style.pixelHeight;
tempheight+=12;
if(tempheight>270) { //사진 세로크기
  a.style.pixelHeight=270;  //사진 세로크기
  sizeismax++;
}
else a.style.pixelHeight=tempheight;

if(sizeismax!=2) setTimeout("aplay();",10);
else {
  b.style.visibility="visible";
  a.style.visibility="hidden";
}
}

function showb() {
a.style.pixelWidth=0;
a.style.pixelHeight=0;
a.style.visibility="visible";
aplay();
}

function hideb() {
b.style.visibility="hidden";
}
</script>


<body>와 </body>부분에 Layer를 2개 만들어 줍니다.
*****************************************
<div id="b" style="position:absolute; left:55px; top:169px; width:178px; height:274px; z-index:1; visibility:hidden;">
<img src="page1.jpg" width="178" height="270" border="2">
</div>

<div id="a" style="position:absolute; left:55px; top:169px; width:178px; height:270px; z-index:1; visibility:hidden;border-width:1; border-style:solid; border-color:#3A3A3A;"></div>


[설명]
레이어 a 는 레이어b의 그림을 감추기 위한 역할을 합니다.
레이어 b 는 그림을 보여주는 역할을 합니다.


링크부분
*****************************************
<a href="#" onclick="showb()">보이기</a>
<a href="#" onclick="hideb()">감추기</a>