开发者

Issue with window.close and chrome

I'm trying to close a child window with JavaScript, and in Firefox everything works fine but in Chrome the window doesn't close.

Here is what I'm using

$(document).ready(function() {
    if (window.opener && !window.opener.closed)
        window.opener.location = "http://www.website.com"
    window.close();
});

I tried a suggestion on google, but to no avail.

Anyone h开发者_StackOverflow社区aving a similar issue or know of a work-around?


I know this question is old, but I ran into the same problem. This worked for me:

window.open('', '_self', ''); //bug fix
window.close();


If previously you open some other window by window.open()

This don't work:

window.open(...)
window.open('', '_self', '');
window.close();

But work:

window.open(...);
setTimeout(function(){
    window.open('', '_self', '');
    window.close();
}, 100);


Something like this should also work:

setTimeout(function() {
    window.close();
},50);


I think it's working in Chrome Kiosk ( Fullscreen ) mode. Tried successfully.


top.window.close() works for me. Tested on IE, FF, Chrome, Safari and Opera.


This worked for me

var win = window.open("about:blank", "_self");
win.close();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜