读书人

关于 onkeydowm 事件触发任务解决办法

发布时间: 2012-08-14 10:39:57 作者: rapoo

关于 onkeydowm 事件触发任务

JScript code
 function enterSumbit(hotarea,typeFlag){         var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异        if (event.keyCode == 13){         classidcheck(hotarea,typeFlag);     }    }  function classidcheck(hotarea,typeFlag){ var pname = document.getElementById("name").value; var cstr = document.getElementById("classstr").value; window.location.href="/system/hot/add_hot_ticket2.jsp?hotarea="+hotarea+"&typeFlag="+typeFlag+"&name="+pname+"&classstr="+cstr;  [color=#FF0000]alert("ok");[/color]}


HTML code
按商品名称查询:<input name="name" class="text-line" value=""  onkeydown="enterSumbit('<%=hotarea%>','<%=typeFlag%>')" />


为什么一定要 alert(“OK”) 回车后它才执行?
多谢!

[解决办法]
你把alert("ok")换成return false试试
[解决办法]
document.getElementById("name") //应该传入id值,而不是name
HTML code
<input id="hotarea" name="name" class="text-line" value=""  onkeydown="enterSumbit('<%=hotarea%>','<%=typeFlag%>')" />document.getElementById("hotarea").value 

读书人网 >JavaScript

热点推荐