팝업메뉴를 위한(?) 함수...중에 windows.setTimeout(action, msec) 라는 함수가 있다.
뭐랄까... 팝업 자체에서 가질 수 있는 마우스 나가기...에 대해 오류를 어느정도 막아준다고 할까...
예를 들어 이런 경우...
...
* popup Sample *
...
마우스포인터가 회색 안에서 밖으로 나가면 내용물(?)을 바꾸자는 내용인데,
회색 범위를 미쳐 다 빠져나가기 전에 바뀌는 현상도 나타날 수 있다.
(글자가 있는 곳과 없는 곳 사이에서...)
div 가 "바꾸기전"을 포함하지만, a 태그를 따로(?) 인정(?)하기 위해 잠시 나간척(?)을 해준 것.
popup 으로 이런 식의 모듈을 만든다면 메뉴 클릭하기 전에 팝업이 꺼질 수 있는 현상이 문제가 되서,
결국(?)... 내 나름대로의 해결방법을 setTimeout 에서 찾게 되었다.
...
var settoTwoTimer='';
function changeTwo() {
document.all['isTwo'].innerText="바꿨다";
}
function settoTwo() {
settoTwoTimer=setTimeout(changeTwo, 200); // 200msec 후 작동
}
function releasesettoTwo() {
if(settoTwoTimer) { clearTimeout(settoTwoTimer); settoTwoTimer=''; }
}
</SCRIPT>
<DIV style="BACKGROUND-COLOR: #eeeeee; width:200px; height:50px;" id=isTwo onmouseover=releasesettoTwo(); onmouseout=settoTwo();><a href=http://killofki.tistory.com/>바꾸기전</a></DIV>
...
* popup Sample *
...
생각보다 꽤(?) 복잡해졌다.
뭐... 팝업을 만드는 함수 자체가 복잡할테니 그러려니...하긴 하지만,
= =;... 그냥 a 태그 쓰지말고 만들어야하나...하는 생각도 든다.
...
NN:
자... 이제 마지막으로, Netscape Navigator 계열에서도 이게 잘 돌아가야 할텐데...
innerText 를 NN 계열에서는 textContent 로 쓰는 관계로,
항목을 추가해본다.
...
var settoThreeTimer='';
function changeThree() {
if (document.all) // if IE
document.all['isThree'].innerText="바꿨다";
else // maybe NN
document.getElementById('isThree').textContent="바꿨다";
}
function settoThree() {
settoThreeTimer=setTimeout(changeThree, 200); // 200msec 후 작동
}
function releasesettoThree() {
if(settoThreeTimer) { clearTimeout(settoThreeTimer); settoThreeTimer=''; }
}
</SCRIPT>
<DIV style="BACKGROUND-COLOR: #eeeeee; width:200px; height:50px;" id=isThree onmouseover=releasesettoThree(); onmouseout=settoThree();><a href=http://killofki.tistory.com/>바꾸기전</a></DIV>
...
* popup Sample *
...
사실, object 선택부분을 getElementId 로 공통화시키는 것이 표준형이라
변수를 하나로 묶는 것도 좋지만,
일단... 이런 식으로 마무리했다.
DoubleVictory killofki@.
'windows .setTimeout()' 카테고리의 다른 글
animation] 여러장을 넓게(?) 펼져서 적용해봤습니다. (0) | 2012.04.03 |
---|---|
iframe] resize() 에 관한 시도... (0) | 2009.12.21 |
바탕화면 이미지에 뿌연 효과(?)를... (0) | 2009.10.08 |
timer threading? (0) | 2009.09.08 |