子ウインドウから、親ウインドウを遷移させ、フォーカスを当て、更にその画面から子ウインドウにフォーカスを当てる
※しかしこれだとFx4以上は意図通りになるが他が上手く行かなくなる
via
Firefox4.0で子窓から親窓へのフォーカス(window.opener.focus)が利かない | そぷログ
※IE8、Chrome、Safari5、Fx3.6では問題ないことを確認しています。
というように、window.blur()、window.opener.focus()の辺りが上手く反応しない
このため
・IE9 追記;IE9は大丈夫かも
・Fx4以上
は意図通りに動いてくれないので
1.親→子を開く
if(fWinClosed(winObj)){ var winObj = window; winObj = open(theURL,targetName,'scrollbars=yes,resizable=yes,toolbar=no,location=yes,directories=no,status=yes,menubar=no,width='+theW+',height='+theH+''); winObj.focus(); }
2.子→親にフォーカスを当てる
<a target="main" href="URL">リンク</a>
ということでtarget="main" で親へリンク
3.再び親→子を開く
if(fWinClosed(winObj)){ var winObj = window; winObj = open(theURL,targetName,'scrollbars=yes,resizable=yes,toolbar=no,location=yes,directories=no,status=yes,menubar=no,width='+theW+',height='+theH+''); winObj.focus(); }
1と同じスクリプトを動かす。