Days of the Condor

Projects About

Programmatically focus content inside an iFrame

Oct 5, 2011

This is a short one. On the Pixie landing page I was trying to use jQuery to focus on a game embedded via an iFrame. I tried

$ ->

but that didn’t work.

It turns out to get this working you need setTimeout. I guess the browser isn’t done loading the iFrame contents by the time jQuery says the DOM is ready.

$ ->
  setTimeout ->
  , 100

Here’s the related Stack Overflow question