javascriptの「with」キーワードと親子ウィンドウの関係、特にwindow.openerに特有の何かに気づきました。私はこれを親ウィンドウからテストしていません。子だけですが、以下の例では注目に値します-
親ウィンドウ(Parent.html):
// global scope
function ParentFunc() { alert("I am a parent function"); }
子ウィンドウ(Child.html):
// global scope
var baseWin = window.opener;
// "this" keyword corresponds to Child.html when function below is called
function Child_Onclick_Func()
{
alert("Hi, from Child");
with (baseWin)
{
ParentFunc();
alert("Hi, from Parent");
}
alert("Hi, back to Child");
}
この場合、「with」キーワードは親ウィンドウに切り替わり、2番目のアラートは親ウィンドウにも暗黙のオンフォーカスを発生させます。「with」が親ウィンドウに切り替わるとは思いもしませんでしたが、今では理にかなっています。