jQuery 1.10.2事件没有在flash对象上触发

时间:2013-11-27 21:58:31

标签: javascript jquery flash events

HTML

<div id="div" tabindex="1">Div</div>
<object id="swf" tabindex="1"><!--Embedded with swfobject--></object>

JS

//This works, so it looks like focus should work an any element with tabindex set
$('#div').on('focus', function()
{
    console.log('Div focus event');
});

//This works, so it looks like the browser and Flash support the events
$('#swf').onblur = function()
{
    console.log('SWF onblur');
}

//This does not work
$('#swf').on('focus', function()
{
    console.log('SWF focus event');
});

为什么onfocus有效,但on('focus')没有?除了转发事件之外,jQuery还在做什么吗?

1 个答案:

答案 0 :(得分:2)

试试这个

$(body).on('focus', '#swf', function(){}); 

希望有所帮助