onkeypress="return isNumberKey(event, this);" call the function twice in IE8 per pressed in javascript - Stack

Does anyone know what is going on here? When I pressed the key once, in IE8 it's always calls the

Does anyone know what is going on here? When I pressed the key once, in IE8 it's always calls the function in javascript twice. It's working fine by only call the fundtion once when the keypredd in firefox but not in IE8.

HTML:

<input onkeypress="return isNumberKey(event, this);"  />

Javascript:

function isNumberKey(evt, obj)
{

    alert('unavailable'). 
    return false

}

Does anyone know what is going on here? When I pressed the key once, in IE8 it's always calls the function in javascript twice. It's working fine by only call the fundtion once when the keypredd in firefox but not in IE8.

HTML:

<input onkeypress="return isNumberKey(event, this);"  />

Javascript:

function isNumberKey(evt, obj)
{

    alert('unavailable'). 
    return false

}
Share Improve this question edited Sep 8, 2009 at 1:58 Jin Yong asked Sep 8, 2009 at 1:13 Jin YongJin Yong 43.8k72 gold badges144 silver badges194 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

Works for me IE8 on Vista, (8.0.6001.18813)

<script>
function isNumberKey() {
    document.title += 1;
    return false;
}
</script>
<input type="text" onkeypress="return isNumberKey();">

I only see the title get appended a single "1" at a time. Maybe you have some other code going amiss? Your posted code has an obvious syntax error, so maybe there's something else you're leaving out?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744791441a4593938.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信