Skip to main content

Setting Keyboard Focus on Flex onLoad

When you refresh the browser with a flex app running fullscreen, obviously the flex app should be focused…. but it’s not 🙁

Here’s a really easy way to set keyboard focus on your flex or flash embeded code. Basically, just paste the code below into the bottom of your html. After the page loads, this code gets called and sets the focus on your embeded swf.

FLEX Note: You’ll want to apply this code to your “html-template/index.template.html”.
FLASH Note: If you are using this code outside of flex then you will want to replace ${application} with the ID of your swf.

<script language="JavaScript" type="text/javascript">
document.onload = document.getElementById('${application}').focus();


note: not sure this works in IE. will test soon.




I lead a fantastic team of WordPress developers building enterprise level WordPress systems. On occasion I have been known to speak at conferences on the topics of Freelancing, WordPress, and the meaning of life, though I tend to spend much of my performance energy on my music. Perhaps one day I will figure out how to merge the two without having to write songs about debugging Javascript.