Chrome 59 で window.open の挙動が変わった
JavaScript で新しいウィンドウを開くため、このようなコードを書いていたのですが、Chrome 59 になってから新しいタブで開くようになってしまいました。
window.open('http://example.com/', '_blank', 'width=640, height=480, location=yes')
window.open の第3引数
feature から、アドレスバーを表示するためのオプション location=yes
を取り除くことで、タブではなくウィンドウで開くようになりました。
window.open('http://example.com/', '_blank', 'width=640, height=480')
こうなった原因を探るため Chrome 59 のコミットログ を window.open
で検索したところ window.open() should gate new tab/new popup based on toolbar visibility. (e507bb3) が関係してそうでした。
window.open() should gate new tab/new popup based on toolbar visibility.
Previously, Chrome required that toolbar, menubar, scrollbars, status, resizable were all set to enabled to open a window as a new tab rather than a new popup. However, this causes developer frustration if one of window features is accidentally omitted (as it then defaults to disabled).
Instead, just use toolbar visibility to determine whether or not window.open() creates a new popup or a new tab, which matches Firefox.
なるほど。toolbar についても調べたところ、確かに設定次第でポップアップかどうかが変わりました。
// 新しいタブになる window.open('http://example.com/', '_blank', 'width=640, height=480, toolbar=yes') // 新しいウィンドウ(ポップアップ)になる window.open('http://example.com/', '_blank', 'width=640, height=480, toolbar=no') window.open('http://example.com/', '_blank', 'width=640, height=480')
Chrome 59 のソースを調べたことのメモ
feature をパースしているのは WindowFeatures.cpp のようです。
どこかに location を toolbar として見るコードがあるはずですが、見つけられませんでした。
(6月20日追記)
location=yes
の有無でどうなるか、IE 11, Edge, 14, Chrome 59, Firefox 54 で動作確認しました。
結果はリンク先を見ての通りですが、特に挙動が違ったところとして IE 11 だけ location=yes の時にアドレスバーの中身を編集できました。