説明
- ウインドウにフォーカスを与えるメソッド。
- JavaScriptによるフォーカス移動を禁止する設定項目を用意しているブラウザでは,ブラウザの設定が優先される。
用例
ボタンフォームをクリックしたときに新しく開くウインドウにフォーカスがくる。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>focus</title>
<script type="text/javascript">
<!--
function wopen_1(){
var WO;
WO=window.open("","WindowFocus_1", "toolbar=no,location=no,
directories=no,width=300,height=450");
WO.window.focus();
WO.document.write("<html><head><title>WF1</title></head>");
WO.document.write("<body>");
WO.document.write("このウインドウが前にきます");
WO.document.write("</body>");
WO.document.write("</html>");
WO.document.close();
}
//-->
</script>
<style type="text/css">
<!--
body { background-color: #ffffff; }
-->
</style>
</head>
<body>
*ウインドウにフォーカスを与える
<p>
<form>
<input type="button" value="前に移動するウインドウ" onClick=
"wopen_1()">
</form>
</p>
</body></html>
この用例を実行する