■以下のボタンをクリックするとウインドウの操作ができます。



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>新しくウインドウを開く、閉じる、閉じられていることを確認したい</title>
<script type="text/JavaScript">
<!--
function win_open1(){
win1=window.open("118p_2.html","NewWindow1");
}
function win_close1(){
win1.window.close();
}
function win_open2(){
win1=window.open("118p_3.html","NewWindow1");
}
function win_open3(){
window.open("118p_2.html");
}
function win1_closed(){
if (win1.window.closed){
alert("win1(NewWindow1)ウインドウはすでに閉じられています。");
} else {
alert("win1(NewWindow1)ウインドウは開いています。")
}
}
// -->
</script>
</head>
<body>
<p>■以下のボタンをクリックするとウインドウの操作ができます。</p>
<form name="frm1">
<p><input type="button" value="ウインドウを新規に開く(118p_2.html表示)" onclick="win_open1()"></p>
<p><input type="button" value="指定ウインドウを閉じる" onclick="win_close1()"></p>
<p><input type="button" value="指定ウインドウに別のHTMLを表示(118p_3.html表示)" onclick="win_open2()"></p>
<p><input type="button" value="ウインドウが閉じられているか確認" onclick="win1_closed()"></p>
<hr>
<p><input type="button" value="ウインドウ名を省略(118p_2.html表示)" onclick="win_open3()"></p>
</form>

</body>
</html>



★解説★