JavaScript open in a new window, not tab

前端 未结 15 1288
余生分开走
余生分开走 2020-11-21 22:18

I have a select box that calls window.open(url) when an item is selected. Firefox will open the page in a new tab by default. However, I would like the page t

15条回答
  •  南方客
    南方客 (楼主)
    2020-11-21 22:44

    I just tried this with IE (11) and Chrome (54.0.2794.1 canary SyzyASan):

    window.open(url, "_blank", "x=y")
    

    ... and it opened in a new window.

    Which means that Clint pachl had it right when he said that providing any one parameter will cause the new window to open.

    -- and apparently it doesn't have to be a legitimate parameter!

    (YMMV - as I said, I only tested it in two places...and the next upgrade might invalidate the results, any way)

    ETA: I just noticed, though - in IE, the window has no decorations.

提交回复
热议问题