ウィンドウ座標を設定する

書式

 windowObj.setLocation(y, x)

windowObj : ウィンドウオブジェクト
x: X座標
y : Y座標

説明

 ウィンドウ座標を設定するにはsetLocation()を使います。最初のパラメータがY座標、2番目のパラメータがX座標になります。

サンプルコード [実行]

<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 win;
window.onload = function(){
win = new Window("win01", {
title: "Sample", className: "dialog",
top:50, left:120,
width:320, height:240,
zIndex: 100, resizable: true, draggable:true
});
win.setDestroyOnClose();
win.show();
}
function setXY(){
win.setLocation($F("winY"), $F("winX"));
}
// --></script>
</head>
<body>
<h1>ウィンドウ座標を設定する</h1>
<form>
X座標:<input type="text" id="winX" value="150" size="6"><br>
Y座標:<input type="text" id="winY" value="140" size="6"><br>
<input type="button" value="座標を設定" onClick="setXY()">
</form>
</body>
</html>