ウィンドウを中央に表示する

書式

 windowObj.showCenter(modal, top, left)

windowObj : ウィンドウオブジェクト
modal : モーダルモード(true : する、false : しない)【省略可能】
top : Y座標【省略可能】
left : X座標【省略可能】

説明

 ウィンドウを中央に表示するにはshowCenter()を使います。最初のパラメータにtrueを設定するとウィンドウ外でクリックしても無効となります。初期値ではfalseになっています。2番目と3番目のパラメータを指定すると、指定した座標にウィンドウが表示されます。

サンプルコード [実行]

<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"><!--
window.onload = function(){
var win = new Window("win01", {
title: "Sample", className: "dialog",
top:50, left:120, zIndex: 100,
width:320, height:240,
resizable: true, draggable:true
});
win.setDestroyOnClose();
win.showCenter();
}
// --></script>
</head>
<body>
<h1>ウィンドウを中央に表示する</h1>
</body>
</html>