Used ownerDocument instead of window.content.document

Fixes the image inside iframe case