Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
94 views
in Technique[技术] by (71.8m points)

javascript - 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 having a similar issue or know of a work-around?

question from:https://stackoverflow.com/questions/2032640/issue-with-window-close-and-chrome

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...