ウィンドウの処理をまとめて行う

書式

 windowObj.setDelegate(delegate)

windowObj :ウィンドウオブジェクト
delegate : 代表して処理を行うオブジェクト

説明

 ウィンドウの処理をまとめて行うにはsetDelegate()を使います。パラメータには代表して処理を行うオブジェクトを指定します。このオブジェクトにはcanCloseメソッドが定義されている必要があります。

サンプルコード [実行]

<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:50, left:10, width:320, height:240,
zIndex: 100, resizable: true, draggable:true });
win01.setDestroyOnClose();
win01.setDelegate(new allClose);
win01.show();

win02 = new Window("win02", {
title: "ウィンドウ02", className: "dialog",
top:80, left:150, width:320, height:240,
zIndex: 101, resizable: true, draggable:true });
win02.setDestroyOnClose();
win02.setDelegate(new allClose);
win02.show();
}
function allClose(){
this.canClose = function(){
win01.destroy();
win02.destroy();
}
}
// --></script>
</head>
<body>
<h1>ウィンドウを全て閉じる</h1>
</body>
</html>