问题描述
在回答调用 open()
和 window.open()
,请尝试下面的示例在Firefox中(在11.0测试):
-
(调用
打开
; 在FF中的新选项卡中打开,前提是打开在新选项卡中打开新窗口设置,它是默认的) : http://jsfiddle.net/9kqp5/ (calls
open
; opens in new tab in FF, provided that the "Open new windows in new tab instead" setting is on, which it is by default)http://jsfiddle.net/HLbLu/ (calls
window.open
; opens in new small window)
<脚本>
var a = 2;
函数hello(){alert(this.a); }
hello();
window.hello();
< / script>
调用函数 hello
同样,包括有相同的这个
!!!
One你的小提琴调用 window.open
而另一个调用 document.open
,因为内联属性事件处理程序很奇怪。所以你最终在
,因为你传递了3个参数,所以应该调用 window.open
。行为上的差异似乎是Firefox中的一个错误。我提交了就这个。
In answering my question Pumbaa80 found a difference between calling open()
and window.open()
, try the following examples in Firefox (tested on 11.0):
But why on earth there is a difference? If I try the following example:
<script>
var a = 2;
function hello() { alert(this.a); }
hello();
window.hello();
</script>
Both variants of calling function hello
work exactly the same, including having the same this
!!!
One of your fiddles is calling window.open
while the other is calling document.open
, because the scope chain in inline attribute event handlers is weird. So you end up at http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#dom-document-open
That said, since you pass 3 arguments, this should be invoking window.open
. The difference in behavior seems to be a bug in Firefox. I filed https://bugzilla.mozilla.org/show_bug.cgi?id=741266 on that.
这篇关于Firefox中的open()和window.open()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!