設定されているイベント処理を解除する

書式

 Windows.removeObserver(observer)

observer : 各種イベントに対する処理

説明

 Windows.addObserver()で設定したイベント処理を解除するにはWindows.removeObserver()を使います。パラメータにはWindows.addObserver()で設定したものを指定します。

サンプルコード [実行]

<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(){
win01 = new Window("win01", { title: "Sample", className: "dialog",
top:100, left:10, zIndex: 100, width:320, height:240,
resizable: true, draggable:true });
win02 = new Window("win02", { title: "Sample", className: "dialog",
top:120, left:50, zIndex: 100, width:320, height:240,
resizable: true, draggable:true });
msgMoveEvent = {
onStartMove: function(eventName, winObj) {
$("result").innerHTML = "移動中:"+winObj.getId(); },
onEndMove: function(eventName, winObj) {
$("result").innerHTML = "移動完了:"+winObj.getId(); } }
Windows.addObserver(msgMoveEvent);
win01.setDestroyOnClose();
win01.show();
win02.setDestroyOnClose();
win02.show();
}
function unreg(){
Windows.removeObserver(msgMoveEvent);
}
// --></script>
</head>
<body>
<h1>イベントに応じた処理を解除する</h1>
<form>
<input type="button" value="解除" onClick="unreg()">
</form>
<div id="result"></div>
</body>
</html>