フォーカスされているウィンドウを取得する

書式

 windowObj = Windows.getFocusedWindow()

windowObj : ウィンドウオブジェクト

説明

 フォーカスされているウィンドウを取得するにはgetFocusedWindow()を使います。戻り値はフォーカスされているウィンドウオブジェクトになります。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="default.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="effects.js"></script>
<script type="text/javascript" src="window.js"></script>
<script type="text/javascript"><!--
var win01, win02;
window.onload = function(){
win01 = new Window("win01", {
title: "ウィンドウ01", className: "dialog", top:100, left:60, zIndex: 100,
width:320, height:240, resizable: true, draggable:true });
win01.setDestroyOnClose();
win01.show();

win02 = new Window("win02", {
title: "ウィンドウ02", className: "dialog", top:150, left:180, zIndex: 101,
width:320, height:240, resizable: true, draggable:true });
win02.setDestroyOnClose();
win02.show();
}
function checkFrontWindow(){
var winObj = Windows.getFocusedWindow();
$("result").innerHTML = winObj.getId();
}
// --></script>
</head>
<body>
<h1>最前面のウィンドウIDを表示する</h1>
<form>
<input type="button" value="表示" onClick="checkFrontWindow()">
</form>
<div id="result"></div>
</body>
</html>