window.open 返回 true 时始终关闭
在 IE9 上,window.open() 始终返回 true 关闭的属性。这是我在 Facebook 上的 oAuth 代码:
$(window).ready(function(){
$("#linkFacebook").click(LoginFb);
});
var winInter;
var win;
function LoginFb(){
var linkFB = '@Url.Action("LogOn", "Facebookk")';
win = window.open(linkFB, 'FB', 'toolbar=0,scrollbars=1,status=1,menubar=1,location=0,resizable=1,width=560,height=500');
winInter = setInterval(checkWindow, 1000);
}
function checkWindow()
{
try {
if (win.closed)
{
clearTimeout(winInter);
window.location.href = "@Url.Action("Index", "User")";
}
}
catch (e)
{ }
}
我在 msdn 上发现了这个错误: http://support.microsoft.com/kb/241109 ,但工作环境并不工作。因为 window.opener.childOpen 总是返回 null。
我还尝试了以下代码:
var WindowRef = null;
function openWindow(url, name, props) {
if(WindowRef == null){
WindowRef = window.open(url, name, props)
}
else{
WindowRef.document.location = url
}
if (!WindowRef.opener) {
WindowRef.opener = self;
}
WindowRef.focus();
return WindowRef;
}
window.open() returns always the porpertie closed in true, on IE9. This is my code to oAuth on Facebook:
$(window).ready(function(){
$("#linkFacebook").click(LoginFb);
});
var winInter;
var win;
function LoginFb(){
var linkFB = '@Url.Action("LogOn", "Facebookk")';
win = window.open(linkFB, 'FB', 'toolbar=0,scrollbars=1,status=1,menubar=1,location=0,resizable=1,width=560,height=500');
winInter = setInterval(checkWindow, 1000);
}
function checkWindow()
{
try {
if (win.closed)
{
clearTimeout(winInter);
window.location.href = "@Url.Action("Index", "User")";
}
}
catch (e)
{ }
}
I found this bug on msdn:
http://support.microsoft.com/kb/241109 , but the work arround does not work. Because window.opener.childOpen always returns me null.
I also try the following code:
var WindowRef = null;
function openWindow(url, name, props) {
if(WindowRef == null){
WindowRef = window.open(url, name, props)
}
else{
WindowRef.document.location = url
}
if (!WindowRef.opener) {
WindowRef.opener = self;
}
WindowRef.focus();
return WindowRef;
}
which I find here: window.open() returns undefined or null on 2nd call
EDIT: on http://www.myspace.com works on IE. I do't understand how they do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
open()
是 window 的一种方法,因此在非严格比较中它将始终评估为 true。您想查看弹出窗口的close
属性,请使用以下内容(已编辑,抱歉,我第一次没有正确回答您的问题):open()
is a method of window, so it will always evaluate to true in a non-strict comparison. You want to look at theclosed
property of your popup, play with the following (edited, sorry, I didn't answer your question correctly the first time):