웹마스터 팁


<script language=javascript>
<!--

var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function getRef(id) {
        if (isDOM) return document.getElementById(id);
        if (isIE4) return document.all[id];
        if (isNS4) return document.layers[id];
}

var isNS = navigator.appName == "Netscape";

function moveRightEdge() {

        var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
        
        if (isNS4) {
                yMenuFrom   = divMenu.top;
                yMenuTo     = windows.pageYOffset + 405;   // 위쪽 위치
        } else if (isDOM) {
                yMenuFrom   = parseInt (divMenu.style.top, 10);
                yMenuTo     = (isNS ? window.pageYOffset +405 : document.body.clientHeight + document.body.scrollTop - 45 ); // 위쪽 위치
                if(!isNS) {
                        if( yMenuTo > document.body.scrollHeight - 250 ) yMenuTo = document.body.scrollHeight - 235;
                        if( yMenuTo < 65 ) yMenuTo = 65;
                }
        }
        
        timeoutNextCheck = 500;
        
        if (yMenuFrom != yMenuTo) {
                yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 10);
                if (yMenuTo < yMenuFrom)
                        yOffset = -yOffset;
                if (isNS4)
                        divMenu.top += yOffset;
                else if (isDOM)
                        divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
                        timeoutNextCheck = 10;
        }
        setTimeout ("moveRightEdge()", timeoutNextCheck);
}
//-->
</script>

<a href="#top" onFocus="blur()">
<img id=divMenu style="left: 880; top:260; visibility: visible; width: 13px; position: absolute" src="탑버튼 이미지경로" border="0" height="33"></a>

<script language=javascript>
<!--
if (isNS4) {
        var divMenu = document["divMenu"];
        divMenu.top = windows.pageYOffset + 405;
        divMenu.visibility = "visible";
        moveRightEdge();
} else if (isDOM) {
        var divMenu = getRef('divMenu');
             divMenu.style.top = (isNS ? window.pageYOffset +405 : document.body.clientHeight + document.body.scrollTop - 45 );
        if(!isNS) {
                if( divMenu.style.top > document.body.scrollHeight - 250 ) divMenu.style.top = document.body.scrollHeight - 235;
                if( divMenu.style.top < 65 ) divMenu.style.top = 65;
        }
                        
        divMenu.style.visibility = "visible";
        moveRightEdge();
}
//-->
</script>
<!--TOP버튼 끝-->


예제 : http://haksabank.net
* Nytoner님에 의해서 게시물 이동되었습니다 (2005-01-04 16:42)