본문 바로가기

프로그래밍

JavaScript - Bottom 아래로 붙이기

출처 : devnote7.tistory.com

<html>
<head>
<script tyle="text/javascript" language="javascript">
    function calcBottom(){
        var obj = document.getElementById("tblBottom");
        var prev = obj.previousSibling;
        while( prev.nodeName != "TABLE" )
            prev = prev.previousSibling;
  
        var prevBottom = prev.offsetTop + prev.clientHeight;
        var bottomAnchor = document.getElementById("bottomAnchor");
        var pageHeight = bottomAnchor.offsetTop + bottomAnchor.clientHeight;
        var myHeight = obj.clientHeight;
  
        var retVal;
        var margin = 30;
        if( pageHeight >= prevBottom + myHeight + margin )
            retVal = pageHeight - prevBottom - myHeight;
        else
            retVal = margin;
  
        return retVal;
    }
</script>
<style>
    .bottom{
        position:relative; 
        top:expression(calcBottom());
    }
</style>
</head>
<body>
<img style="position:absolute;bottom:0px;visibility:hidden;" id="bottomAnchor" />
<table width="100%" cellpadding="0" cellspacing="0" id="tblBottom" class="bottom">
    <tr>
        <td align="center"><!--#include virtual="/bottom.asp"--></td>
    </tr>
</table>
</body>
</html>