新しいタブではなくポップアップでページを開こうとしていますが、どのブラウザを試しても、ポップアップではなく新しいタブで開くだけです。
<input type="button" value="new win" onclick="window.open('http://yahoo.com', 'width=500, height=400')" />
何か理由は?
新しいタブではなくポップアップでページを開こうとしていますが、どのブラウザを試しても、ポップアップではなく新しいタブで開くだけです。
<input type="button" value="new win" onclick="window.open('http://yahoo.com', 'width=500, height=400')" />
何か理由は?
2 番目のパラメータはウィンドウ名でなければなりません:
<input type="button" value="new win"
onclick="window.open('http://yahoo.com', 'mywindow', 'width=500, height=400')" />
Chrome と Firefox で正常に動作:
2番目のパラメータはnameである必要があります。windowname
<input type="button" value="new win"
onclick="window.open('http://yahoo.com','windowname', 'width=500, height=400')" />
onclick="window.open('http://yahoo.com', 'MyYahoo', 'width=500, height=400, toolbar=no, menubar=no')" />
window.open
方法は以下の通りです。
window.open(URL,name,specs,replace)
これが良い読み物のWindowopen()メソッドです
nameオプション。ターゲット属性またはウィンドウの名前を指定します。次の値がサポートされています。
_blank - URL is loaded into a new window. This is default
_parent - URL is loaded into the parent frame
_self - URL replaces the current page
_top - URL replaces any framesets that may be loaded
name - The name of the window
これはさまざまなブラウザによって制御されているものではありませんか?target = "_ blank"を使用すると、Chromeの新しいタブが開きます。これは、Firefox、Opera、Safari、IEにも当てはまると思います。
問題は、window.open の 3 番目の引数です。3 番目の引数を渡すと、ブラウザーは指定されたウィンドウ名で新しいウィンドウを開きます (2 番目の引数はまだ開かれていません)。
ウィンドウを開きますが、タブを開きます。window.open("http://localhost:5000", "newWindow", "resizable")
window.open("http://localhost:5000", "newWindow")