Use proper window object for iframe in enter/leave

Depends on #789.