<html>
<body>
<form>
<script type="text/javascript">
function tt(){
alert('asdfasdf');
}
function aaa(){
//alert('-------------');
document.getElementById('t2').value=1;
}
</script>
<form>
<input type="text" onblur="tt();"/><br />
<input id="t2" type="text" /><br />
<input type="text" /><br />
<input type="submit" onclick="aaa();return false;"/>
</form>
</body>
</html>
光标停在第一个text上然后enterie下会触发onblur事件而ff下却没有触发onblur事件 目前认为是browser的兼容问题,有什么办法也让ff也触发onblur事件呢(submit还是要的,不要改成button的)
解决方案 »
- apply疑问
- uploadfy附件上传,组件的父标签如果是hidden的则chrome浏览器无法上传
- 请各位朋友帮忙看下这个啊 怎样用select控制文本框的即时更新???
- 请问如何获取当前HTML页面中指定标签内的代码?
- 数据库操作
- <input type="text" id="TalkInTxt" /> 换行
- 如何在浏览器载入html代码之前,先过滤一遍html代码?
- JavaScript 层随着鼠标望下移动,现在想不动,解决了全分相送!
- 新闻发布系统中一个棘手问题,急!急!急!急!急!急!
- 我在选择年月后(点击上下,而不是输入框),自动的把数字写到文本框里
- 求助,javascript变量传递时说传递的数据未定义
- 事件冒泡问题。急!!在线等。
FF addEventListener("onclick",函数名,false)
IE 下应该是attachEvent吧see code<html>
<body>
<form>
<script type="text/javascript">
function tt(){
alert('asdfasdf');
}
function aaa(){
document.getElementById('t2').value=1;
return false;
}</script>
<form>
<input type="text" onblur="tt();"/><br />
<input id="t2" type="text" /><br />
<input type="text" /><br />
<input id="enter" type="submit" value="submit"/>
</form>
<script type="text/javascript">
var ent = document.getElementById('enter');
if(ent.attachEvent){
ent.attachEvent("onclick",aaa);
}else{
ent.addEventListener("click",aaa,false);
}
</script>
</body>
</html>在第一个input里enter后:IE下还是会触发onblur事件然后再submit(实际上没submit) 而FF没有触发onblur但是submit了 - -!
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example </title>
<script type="text/javascript">
function $(id) {
return "string" == typeof(id) ? document.getElementById(id) : id;
}function addEvtToObj(tagName){
var t=tagName;
nList=document.getElementsByTagName(t);
for(var i=0;i<nList.length;i++){
nList[i].onkeypress=function(e){
var e=window.event||e;
var k=e.keyCode | e.which | e.charCode;
if(k==13) handinForm();
}
}
}function handinForm(){
$("form1").action="#"; // here go your URL
$("form1").submit();
alert("已经提交表单了");
}</script>
<style></style>
</head>
<body onLoad="javascript:addEvtToObj('input')">
<form id="form1" name="form1" action="" method="post">
<input id="t1" type="text"/><br />
<input id="t2" type="text" /><br />
<input id="t3" type="text" /><br />
<input id="enter" type="submit" value="submit"/>
</form>
</body>
</html>
if(k==13) aaa(); //修改成你的函数即可
...
<html>
<head>
<title>Example </title>
<script type="text/javascript">
function $(id) {
return "string" == typeof(id) ? document.getElementById(id) : id;
}function addEvtToObj(tagName){
var t=tagName;
nList=document.getElementsByTagName(t);
for(var i=0;i<nList.length;i++){
nList[i].onkeypress=function(e){
var e=window.event||e;
var k=e.keyCode | e.which | e.charCode;
if(k==13) check();
}
}
}function handinForm(){
$("form1").action="#"; // here go your URL
$("form1").submit();
alert("已经提交表单了");
}function check(){
if($("t1").value =="a"){
alert("aaaa");
}else{
$("enter").onclick();
}
return false;
}</script>
<style></style>
</head>
<body onLoad="javascript:addEvtToObj('input')">
<form id="form1" name="form1" action="" method="post">
<input id="t1" type="text"/><br />
<input id="t2" type="text" /><br />
<input id="t3" type="text" /><br />
<input id="enter" type="submit" value="submit" />
</form>
</body>
</html>
t1的value为a时enter后alert有了但确定后仍提交啊