<!doctype html> <input id="outside" style="position: absolute; left: 200vw;"> <!-- intentionally out of view --> <iframe srcdoc="<!doctype html>Something inside <input value='some input'>"></iframe> <script> onload = function() { document.querySelector("iframe").contentDocument.querySelector("input").select(); } </script>