Write directly to iframe document to ensure proper handling of scripts.