Replace instanceof Function with typeof == 'function'

So that it works in iframes too.