What is the difference between open() and window.open() in Firefox?

前端 未结 6 2066
抹茶落季
抹茶落季 2021-01-18 10:16

In answering my question Pumbaa80 found a difference between calling open() and window.open(), try the following examples in Firefox

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 11:01

    This is indeed very strange. It looks like The onclick handler when added as an attribute has some context with a wrapped open function that differs from window.open:

    http://jsfiddle.net/aFujb/

    This happens in latest Firefox, Safari and Chrome. I can't find any explanation or bug report for either browser.

    I tried to find out what's happening in Firefox's source code, but quite honestly it's too much for me atm. Looks there's two different window.open implementations called nsGlobalWindow::Open and nsGlobalWindow::OpenJS, but I'm not sure whether this has something to do with the question.

提交回复
热议问题