解决方案 »

  1.   

    <script type="text/javascript"><!--
    var w = 90;
    var h = 100;
    var str = "";
    var obj = document.getElementById("divStayTopLeft");
    if (obj)str = obj.innerHTML;
    if( typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat'){
    document.writeln('<DIV  style="z-index:9;right:0;bottom:0;height:'+h+'px;width:'+w+'px;overflow:hidden;POSITION:fixed;_position:absolute; _margin-top:expression(document.documentElement.clientHeight-this.style.pixelHeight+document.documentElement.scrollTop);">');
    }
    else {
    document.writeln('<DIV  style="z-index:9;right:0;bottom:0;height:'+h+'px;width:'+w+'px;overflow:hidden;POSITION:fixed;*position:absolute; *top:expression(eval(document.body.scrollTop)+eval(document.body.clientHeight)-this.style.pixelHeight);">');
    }
    document.writeln('<div style="clear:both;margin:auto;height:30px;font-size:16px;overflow:hidden;font-weight:bold;text-align:left;"><a href="javascript:scroll(0,0)" hidefocus="true"><img src="http://hotel.114.com.hk/images/detail_btn_goTop.gif" alt="回到顶部" style="border: 0px;" /></a></div> ');
    document.write('<div style="clear:both;margin:auto;overflow:hidden;text-align:left;">'+str+'</div>');
    document.writeln('</DIV>');
    -->
    </script>参考
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <script>
    function goto(position)
    {
        if(position=="bottom")
        {
            document.documentElement.scrollTop=document.body.clientHeight;
            document.body.scrollTop=document.body.clientHeight;
        }
        if(position=="top")
        {
            document.documentElement.scrollTop=0;
            document.body.scrollTop=0;
        }
    }
    </script>
    </head>
    <body>
    <input type="button" value="到页面底端" onclick="goto('bottom')" />
    <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
    <input type="button" value="到页面顶端" onclick="goto('top')" />
    </body>
    </html>