Using settimeout to give body focus
Posted on 2008-10-18
I have the following code which works great for me:
<body onblur="myfunction();" onload="this.focus();">
The problem is, it doesn't ALWAYS work great as the file with the body tag is within a frame, and sometimes things don't load in the order expected and myfunction() gets run instantly.
So I figured, okay, easy solution, just use setTimeout to make the body take the focus after,say, 5 seconds.
But it's not working. The body is never getting focus, so my onblur function doesn't run.
What can I fix i that gets me the equivalent of
after 5 seconds?