admin管理员组文章数量:1414621
Is there a way to set focus to the embed HTML element using JavaScript? Test case: embedded YouTube videos on a page.
I have no control over the embedded Flash element. So, is there a way to set focus on it by using only JavaScript?
I read somewhere that calling the element.focus() method works only in IE. I need a browser-independent way that works in Chrome/Firefox.
Thanks!
Is there a way to set focus to the embed HTML element using JavaScript? Test case: embedded YouTube videos on a page.
I have no control over the embedded Flash element. So, is there a way to set focus on it by using only JavaScript?
I read somewhere that calling the element.focus() method works only in IE. I need a browser-independent way that works in Chrome/Firefox.
Thanks!
Share Improve this question asked Dec 26, 2009 at 13:45 ankitankit 1,3333 gold badges13 silver badges12 bronze badges4 Answers
Reset to default 2This only works in Internet Explorer.
http://kb2.adobe./cps/155/tn_15586.html
I've tried to do this too, and ended up to a nice solution using jquery:
var gotoflash=jQuery("#flash_file").offset().top;jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: gotoflash}, 1000);
where: <div id="flash_file"> flash object code here </div>
It can be done by adding flash content dynamically, for example with swfobject.
I haven't confirmed this, but you could try:
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
// Call from within another function:
thisMovie("FlashObjectID").focus();
thisMovie("FlashObjectID").showFlash();
// showFlash() is an AS3 ExternalInterface call from JS to .swf which establishes the TextInput.setFocus(); method
source: http://www.htmlforums./archive/index.php/t-64150.html
本文标签: Setting focus to an embedded Flash movieHTML embed element using JavascriptjQueryStack Overflow
版权声明:本文标题:Setting focus to an embedded Flash movieHTML embed element using JavascriptjQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745167101a2645749.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论