"闭合的“;属性异常返回“;window.open”;在JavaScript&歌剧

"closed" property abnormal returned by "window.open" in JavaScript&Opera

本文关键字:open JavaScript 歌剧 amp window 异常 quot 属性 返回      更新时间:2023-09-26

我在Opera中尝试获取弹出窗口的"closed"属性时遇到了一个类似bug的问题。

以下是我执行的操作。

>>> win = open('some url in the same domain with the parent window','name','feature')
Window 
>>> win.closed //at this point, the popup window is not closed
false
>>> win.closed //at this point, the pop window is closed
false //this should be true

正如我所料,第二个"假"应该是"真"。

我在Chrome和Firefox上运行过,没问题。

有线索吗?

PS:我正在使用Opera 11.2,Linux

这在我的Opera版本中运行良好,至少在我在这里组装的测试用例中是这样。

我可以用手或按钮关闭窗口,closed属性显示正确的值。

我在linux上使用Opera 11.61版本。


这是测试用例的代码。

var popup = {};
function pop() {
    popup = window.open('foo', 'foo', "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=200,height=200" ); 
}    
function unpop() {
    popup.close();  
}
function check() {
    alert(({}).toString.call(popup) + ' closed: ' + popup.closed);
}
var b1 = document.body.appendChild(document.createElement('button'));
var b2 = document.body.appendChild(document.createElement('button'));
var b3 = document.body.appendChild(document.createElement('button'));
b1.textContent = 'open';
b2.textContent = 'close';
b3.textContent = 'check';
b1.onclick = pop;
b2.onclick = unpop;
b3.onclick = check;

请升级Opera。在某些早期版本中,有一个已知的错误破坏了correct.closed报告,但在最新版本中应该进行修复。

这似乎是Opera中的一个错误。我发现有人打开错误报告的资源:http://www.highdots.com/forums/javascript/closing-popup-window-new-opera-45642.html

注意响应:

E Michael Brandt写道:

感谢您对此进行确认,并提交错误报告。snip这是一个已知的错误和回归,应该很快就会修复,但我不能保证修复会在下一个小版本中,我不能建议时间表。很抱歉关于由此造成的不便!