Sample Source......................................................................>>>
<SCRIPT language="JavaScript"><!--
var subw = "";
function SubOpen(){ //サブウィンドウを開く
subw = window.open("","neww","width=500,height=300");
}
function SubClose(){ //サブウィンドウを閉じる
if(subw=="")alert("ウィンドウは開かれていません!");
else if(!subw.closed)subw.close();
}
function OpenURL(u){
if(subw=="")alert("ウィンドウは開かれていません!");
else if(!subw.closed){
subw.location.href = u;
subw.document.focus(); //サブウィンドウにフォーカスあて最前面にだす
}else{
alert("ウィンドウが開かれていません!");
}
}
function SubWrite(){ //親のテキスト内容をサブウィンドウに表示
if(subw==""){alert("ウィンドウが開かれていません!");
}else if(!subw.closed){
st = document.form1.txtf.value;
subw.document.write(st);
subw.document.close(); subw.document.focus(); //サブウィンドウにフォーカスあて最前面にだす
}else{
alert("ウィンドウが開かれていません!");
}
}
function SubClear(){ //サブウィンドウのドキュメント内容を消去
if(subw==""){alert("ウィンドウが開かれていません!");
}else if(!subw.closed){
subw.document.open();
subw.document.clear();
subw.document.close();
}else{
alert("ウィンドウが開かれていません!");
}
}
function ChangeColor(b,f){ //サブウィンドウの背景色と文字色を変える
if(subw=="")alert("ウィンドウは開かれていません!");
else if(!subw.closed){
subw.document.bgColor = b;
subw.document.fgColor = f; subw.document.focus(); //サブウィンドウにフォーカスあて最前面にだす
}else{
alert("ウィンドウが開かれていません!");
}
} function ChangeWin(w,h){ subw.window.resizeTo(w,h); }
//--></SCRIPT>
</head>
<body>
<button onclick="SubOpen();">サブウィンドウ(子)を開く</button>
<button onclick="SubClose();">サブウィンドウ(子)を閉じる</button>
<form name="form1"> ●サブウィンドウに既存のページを開く<br>
<input type="radio" name="url" value="../aaa/start.htm" onclick="OpenURL(this.value)">はじめに
<input type="radio" name="url" value="../aaa/books.htm" onclick="OpenURL(this.value)">参考書籍
<input type="radio" name="url" value="../basic/user2.htm" onclick="OpenURL(this.value)">ユーザーの使用プラウザを判別
●サブウィンドウに表示するテキストを入力<br>
<textarea name="txtf" rows="3" cols="40"></textarea><br>
<input type="button" name="btwrite" value="サブウィンドウに表示" onclick="SubWrite();"> <input type="button" name="btclear" value="サブウィンドウ内容をクリア" onclick="SubClear();">
<br><br>
●<input type="button" name="btcolor" value="サブウィンドウの色を変える" onclick="ChangeColor('black','white');"> <input type="button" name="btcolor2" value="サブウィンドウの色を元に戻す" onclick="ChangeColor('','');"> ● <input type="button" name="btcolor" value="サブウィンドウのサイズを大きくする" onclick="ChangeWin(700,400);"> <input type="button" name="btcolor2" value="サブウィンドウのサイズを元に戻す" onclick="ChangeWin(500,300);">
</form>