开发者

Capturing keyboard shortcuts in an iframe: focusing?

开发者 https://www.devze.com 2023-01-04 21:17 出处:网络
I\'m creating an IFrame to house an app that wants to listen to keypress events -- is there any way to give this iframe focus, so keypresses get passed to its own handlers, and not to the main p开发者

I'm creating an IFrame to house an app that wants to listen to keypress events -- is there any way to give this iframe focus, so keypresses get passed to its own handlers, and not to the main p开发者_StackOverflow社区age's? (Clicking within the iframe works, but makes for an awful user-interface...)

Thanks!

-B


calling focus on the iframe itself does the trick. E.g. in jquery:

$("#MyIFrame").focus()
0

精彩评论

暂无评论...
验证码 换一张
取 消