<!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>
<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>
解决方案 »
- ExtJS如何获取 Store某一单元格的控件?
- extjs 上传文件 下载文件
- 高手分析下这个选项卡JS代码
- ie6下关于select控件focus和disabled的问题
- javascript怎么取得绑定DropDownList的value值
- 请问怎样在JS中判断单击的是表单中的哪一个按钮
- 急,我想用Javascript 实现多个选择的对话框,即含有YES和Nod
- 寻找上海地区美工兼职
- 关于在<form>里抓鼠标具体位置的问题??请各位帮帮忙,定当高分相送!!~
- iview冒号绑定了方法,这是什么用法?
- 散分!!向大家介绍一个flex开发的web程序,多多批评
- js中如何接受ctrl+c的文本
<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>
---------------------------------------------------------------------
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>
---------------------------------------------------------------------
另外,用火狐浏览器中的方法,prevenDefault也是不好使的。
屏蔽按键有多种方法