<!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=gb2312" />
<title>无标题文档</title>
</head>
<body>
<textarea id="n" cols="20" rows="20" onkeydown="stopit(this,event)"></textarea>
<script language="JavaScript" type="text/javascript">
function stopit(obj,e)
{
e=e||window.event
if(e.keyCode=="39" || e.keyCode=="37")
{
obj.blur();
document.onkeyup=function(){obj.focus()}
}
}
</script>
</body>
</html>

解决方案 »

  1.   

    借3楼兄弟的代码来改改:<!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=gb2312" /> 
    <title>无标题文档 </title> 
    </head> 
    <body> 
    <textarea id="n" cols="20" rows="20" onkeydown="return stopit(this,event);"> </textarea> 
    <script language="JavaScript" type="text/javascript"> 
    function stopit(obj,e) 

    e=e||window.event 
    if(e.keyCode=="39" || e.keyCode=="37") 

        return false;

    return true;
    }
    </script> 
    </body> 
    </html>
      

  2.   

    哦,对了!
    ---------------------------------------------------------------------
    function stopit(obj,e) 里的 obj 不需要了.
    这样就行了:
    function stopit(e) 

        e=e||window.event 
        if(e.keyCode=="39" || e.keyCode=="37") 
        { 
            return false;
        } 
        return true;
    }
    ---------------------------------------------------------------------
    而文本域这样就行了:
    <textarea id="n" cols="20" rows="20" onkeydown="return stopit(event);"> </textarea> 
    ---------------------------------------------------------------------
      

  3.   

    大家没明白我什么意思,我的意思是:在我目前的浏览器中用return false取消按键的响应是不好使的。所以你们所说的屏蔽按键根本就不起作用。
    另外,用火狐浏览器中的方法,prevenDefault也是不好使的。
      

  4.   

    非得用return false????
    屏蔽按键有多种方法
      

  5.   

    吊,你那只眼睛看见到我的JS里用return false 了...