메뉴 건너뛰기

조회 수 7003 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
마우스 오버시 이미지를 보여주는 것은 Layer를 이용한다면 쉽게 구현할 수 있습니다.
하지만 마우스가 조금이라도 흔들리면 OnMouseOver이벤트가 다시 발생하게 되어 깜밖이게 되는데.... 본 소스는 이런것을 없앴으며 브라우져 크기에 따른 자동 위치 선정들의 기능이 구현되어 있습니다. 본 소스는 www.creon.co.kr 에서 발췌했습니다.


샘플화면보기
다음의 링크를 열어 확인하세요. 마우스 오버

<script language="javascript">
var divw=0;
var divh=0;
if (document.getElementById || document.all)
document.write('<div id="imgtrailer" style="position:absolute;visibility:hidden;z-index:100;"></div>')
function gettrailobject()
{
if (document.getElementById)
return document.getElementById("imgtrailer")
else if (document.all)
return document.all.trailimagid
}
function gettrailobj()
{
if (document.getElementById)
return document.getElementById("imgtrailer").style
else if (document.all)
return document.all.trailimagid.style
}
function truebody()
{
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function hidetrail()
{
document.onmousemove='';
gettrailobj().visibility="hidden";
}

function showImage(imagename, caption)
{
var img = new Image
img.src=imagename;
thw=img.width;
thh=img.height;
if (thw=="" || thw==0)
{
thw=500;
}
if (thh=="" || thh==0)
{
thh=500;
}
newHTML = '<table cellpadding=5 style="background-color: #FFFFFF; border: 1px solid #888;">';
newHTML = newHTML + '<tr><td align="center" style="padding: 8px 2px 2px 2px;"><img name='target_resize_image[]' onclick='image_window(this)' style='cursor:pointer;' src="' + imagename + '" border="0" ></td></tr>';
if (caption !="")
{
newHTML = newHTML + '<tr><td> &nbsp; &nbsp;' + unescape(caption) + '</td></tr>';
}
newHTML = newHTML + '</table>';
gettrailobj().left="-500px";
divthw = parseInt(thw) + 2;
gettrailobject().innerHTML = newHTML
gettrailobj().visibility="visible";
// 다음의 divw와 divh값을 변경하여 초기 위치를 변경할 수 있습니다.
divw = parseInt(thw)+25;
divh = parseInt(thh)+85;
document.onmousemove=followmouse;
}
function followmouse(e)
{
var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, indow.innerHeight)
if(typeof e != "undefined")
{
if(docwidth < 15+e.pageX+divw)
xcoord = e.pageX-divw-5;
else
xcoord = 15+e.pageX;
if(docheight < 15+e.pageY+divh)
ycoord = 15+e.pageY-Math.max(0,(divh + e.pageY - docheight - truebody().scrollTop - 30));
else
ycoord = 15+e.pageY;
}
else if (typeof window.event != "undefined")
{
if(docwidth < 15+truebody().scrollLeft+event.clientX+divw)
xcoord = truebody().scrollLeft-5+event.clientX-divw;
else
xcoord = truebody().scrollLeft+15+event.clientX;
if(docheight < 15+truebody().scrollTop+event.clientY+divh)
ycoord = 15+truebody().scrollTop+event.clientY-Math.max(0,(divh + event.clientY - docheight - 30));
else
ycoord = truebody().scrollTop+15+event.clientY;
}
gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"
}
< /script>

<br><br><br><br><br>
< div style="width:150px; height: 230px; float: left; margin: 0 0 15 10; padding: 0;">
<img name='target_resize_image[]' onclick='image_window(this)' style='cursor:pointer;' src="/data/file/bbs_lecture/987831222_c634c3a1_pooh.jpg" border="0" width="100" height="100" >
<img name='target_resize_image[]' onclick='image_window(this)' style='cursor:pointer;' src="http://www.creon.co.kr/img/icon_zoom.gif" border="0"
onmouseover="showImage('/data/file/bbs_lecture/987831222_c634c3a1_pooh.jpg', '첫번째 푸우');"
onmouseout="hidetrail();" style="cursor:pointer" >
</div>

  1. No Image 11Sep
    by
    2016/09/11 Views 6003 

    부드럽게 페이지 이동하기

  2. No Image 22Dec
    by
    2016/12/22 Views 7912 

    복사방지+드래그금지+마우스우클릭 금지

  3. No Image 03Feb
    by
    2015/02/03 Views 5951 

    버튼 삭제

  4. No Image 03Feb
    by
    2015/02/03 Views 6408 

    배열의 리터럴 선언, 또다른 배열 선언 방법!

  5. No Image 16Jan
    by
    2019/01/16 Views 1051 

    배열과 Array객체

  6. No Image 01Mar
    by
    2014/03/01 Views 5911 

    배너 램덤으로 부여주기

  7. No Image 04Jul
    by
    2018/07/04 Views 1849 

    반복문 사용할때 태그 식별하기 data-item

  8. 바닐라 JS, ECMAScript 개념

  9. No Image 27Feb
    by
    2014/02/27 Views 6366 

    미디어플레이어 화면크기 조절방법

  10. 문자열 안에 쌍따옴표, 홑따옴표 표시하는 3가지 방법

  11. No Image 03Feb
    by
    2015/02/03 Views 5729 

    문자열 바꾸기

  12. No Image 01Sep
    by
    2016/09/01 Views 6747 

    모바일 홈페이지로 자동 이동하는 방법....

  13. No Image 27Feb
    by 조쉬
    2014/02/27 Views 7003 

    마우스를 오버해서 이미지를 확대해서 보기

  14. No Image 03Feb
    by
    2015/02/03 Views 6530 

    마우스로 이미지크기 조절(자바스크립트)

  15. No Image 01Mar
    by
    2014/03/01 Views 6226 

    마우스대면 글자 없어지는 검색창

  16. No Image 12Jan
    by
    2023/01/12 Views 118 

    마우스 오른쪽버튼 , 드래그 선택 차단

  17. No Image 19Jun
    by
    2015/06/19 Views 8577 

    마우스 드래그, 오른쪽 팝업메뉴, 선택 막기 (IE11, 파이어폭스, 크롬 확인)

  18. No Image 16Jan
    by
    2019/01/16 Views 1179 

    랜덤(Random) / 난수 만들기

  19. No Image 29Apr
    by
    2019/04/29 Views 11051 

    랜덤 배너 노출 스크립트

  20. No Image 01Mar
    by
    2014/03/01 Views 12671 

    라디오버튼 선택 체크여부 radio checked

Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved