Firefox doesn't seem to have a contentWindow property, you should use contentDocument
Update
After a little discussion, I came up with a better solution:
<html> <head> <title></title> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript"> $(function() { $("#xframe").bind("load", function(){ $(this).contents().find("#xa").focus(); }); }); </script> </head> <body> <iframe id="xframe" src="./y.html"></iframe> </body> </html>
In this example, I assume that there is an input field inside y.html that has the identifier "xa". It worked in both Chrome and Firefox.
Old answer
Better yet, use jquery, something like:
<html> <head> <title></title> <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#xframe").focus(); }); </script> </head> <body> <iframe id="xframe" src="./y.html"></iframe> </body> </html>
Of course, you can do extra checking to make sure the iframe is ready.
More information can be found here http://www.w3schools.com/jsref/prop_frame_contentwindow.asp
rfsbsb
source share