<html> <head> <title>TAG index Webサイト</title> </head> <body onLoad="document.form1.field1.focus()"> <form action="#" name="form1"> <p>お名前:<input type="text" name="field1" size="25"></p> </form> </body> </html> フォーカスを合わせたい入力欄を、以下の方法で設定してください。 document.フォーム名.フィールド名.focus() フォーム名 … formタグの name="" で指定した名前(上記の例では form1) フィールド名 … フィールドの name="" で指定した名前(上記の例では field1) ページを表示したときに自動的にフォーカスを合わせるので、bodyタグに
![JavaScript/フォーム/自動的にフォーカスを合わせる - TAG index](https://cdn-ak-scissors.b.st-hatena.com/image/square/4f9442d6a13ed8b2d2bf932784e7d4613227a381/height=288;version=1;width=512/https%3A%2F%2Fwww.tagindex.com%2Fimage%2Fogp%2Fjavascript.png)