本帖最后由 ohnojack 于 2011-12-08 11:19:57 编辑

解决方案 »

  1.   

    你可以这么做,但是你用鼠标选择的时候还是可以下去的,IE,chrome,ff都是
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body style='overflow:hidden'>
    <div style='width:900px;height:1200px;background-color:#555555;position:absolute'>
    <span style='left:100px;top:100px;width:100px;height:100px;foreground-color:#DDDDDD;position:absolute'>hello</span>
    </div>
    </body>
    <script>
    document.onkeypress = function(event){
    if(37<=event.keyCode<=40){
    event.preventDefault();
    }
    }
    </script>
    </html>
      

  2.   

    to p2227 谢谢你的回答,不知道是否还有其他属性可以直接设置。
      

  3.   

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Insert title here</title>
    </head>
    <body>
    <div id="container">
    <div style='width:900px;height:1200px;background-color:#555555;'>
    <span style='left:100px;top:100px;width:100px;height:100px;foreground-color:#DDDDDD;'>hello</span>
    </div>
    </div>
        <script>
         window.onload = function(){
         var div = document.getElementById('container');
         div.style.height = document.documentElement.clientHeight - 16 + "px";
         div.style.overflow = "hidden";
         }
        </script>
    </body>
    </html>
      

  4.   

    to axiheyhey :这个处理很好,就是需要在body下多加个div了
      

  5.   

    To p2227:preventDefault这样处理不太友好,应用中需要方向键的地方较多。
    不知道还有没有更好地法子。