モーダルダイアログを表示するにはモーダルダイアログを表示するには showModalDialog() を使用します。モーダルダイアログ表示中は、親ウィンドウの操作は一切禁止されます。
<script type="text/javascript">
<!--
function func() {
var args = new Array();
args[0] = window;
args[1] = document.f1.t1.value;
args[2] = document.f1.t2.value;
val = showModalDialog("test2.htm", args,
"dialogHeight:100px;dialogWidth:300px");
}
// -->
</script>
<form name="f1">
<input type="text" name="t1">
<input type="text" name="t2">
<input type="button" value="OK" onclick="func()">
</form>
表示されるダイアログの内容も HTML で記述します。dialogArguments で親ウィンドウからの値を取得することができます。また、returnValue で親ウィンドウに値を返すことができます。
<html>
<head>
<title>モーダルダイアログ</title>
<script type="text/javascript">
<!--
var win;
function init() {
win = window.dialogArguments[0];
document.f2.t1.value = window.dialogArguments[1];
document.f2.t2.value = window.dialogArguments[2];
}
function OnOK() {
win.document.f1.t1.value = document.f2.t1.value;
win.document.f1.t2.value = document.f2.t2.value;
window.returnValue = true;
window.close();
}
// -->
</script>
</head>
<body onload="init()">
<form name="f2">
<input type="text" name="t1">
<input type="text" name="t2">
<input type="button" value="OK" onclick="OnOK()">
</form>
</body>
</html>
yVoC[UNLIMITȂ1~]
ECirŃ|C Yahoo yV LINEf[^[Ōz500~`I