티스토리 뷰

   

 

 

 

 

 

 





오래된 소스입니다.

스크롤하면 따라다니는 레이어 소스인데

 

배너나 top 버튼으로 사용할수 있어요~

 

 

 

 

<상단 자바스크립트>

<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 + 0;   // 위쪽 위치
        } else if (isDOM) {
                yMenuFrom   = parseInt (divMenu.style.top, 10);
                yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop) + 470; // 위쪽 위치
        }
        timeoutNextCheck = 500;
        if (yMenuFrom != yMenuTo) {
                yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
                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>

 

 

 

 

 

< body 부분 html >

 

<div id="divMenu" style="position:absolute; left:830px; top:270px; width:80px; z-index:1">
 
<table border="0" cellpadding="0" cellspacing="0" width="80">
<tr><td style="padding-top:10px" align="center"><p><a href="#top" onfocus='blur()'><img src="/web/upload/s_top.gif" border="0"></a></p></td></tr>
</table>
 
</div>     

 

 

 

 

 

 

< 하단 자바스크립트 >

 

 

<script language=javascript>
<!-- //배너 따라다니기?
if (isNS4) {
        var divMenu = document["divMenu"];
        divMenu.top = top.pageYOffset + 100;
        divMenu.visibility = "visible";
        moveRightEdge();
} else if (isDOM) {
        var divMenu = getRef('divMenu');
        divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) + 100;
        divMenu.style.visibility = "visible";
        moveRightEdge();
}
//-->
</script>

 

 

 

 

 

 

   

댓글