谷歌铬造成文本框焦点无限循环 [英] Google chrome causing infinite loop on textbox focus

查看:101
本文介绍了谷歌铬造成文本框焦点无限循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在google chrome上发生了一些奇怪的事情。使用以下代码,我可以获得无数次提醒。



< input type =text/> alert('in');
});

http://jsfiddle.net/XppG9/



Firefox和IE8都可以。



<为什么在chrome中发生这种情况?

解决方案

我想,这是因为在关闭对话框(警告框)之后,焦点返回文本框,因此,该函数将再次触发。


I'm getting some strange happenings on google chrome. With the following code I'm getting an infinite number of alerts.

<input type="text" />

$('input[type="text"]').live('focus', function(event) {
    alert('in');
});

http://jsfiddle.net/XppG9/

Firefox and IE8 are both fine.

Why is this happening in chrome?

解决方案

I think, it's because after you close the dialog (alert box), the focus returns on the textbox, therefore, the function will fire again.

这篇关于谷歌铬造成文本框焦点无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆