Unified way of closing a browser window in JavaScript?
Is the开发者_如何学JAVAre a way to simply close a browser window, guaranteed? Last time I heard, calling window.close()
or self.close()
only works when the current window is launched from another window. Is there a way to get the majority of browsers to close the current window when this isn't so?
There is no way to close a parent window via script without prompting in any major browser.
So nope, no guarantees. On a child window, window.close
and self.close
both work great.
in firefox you can't close the window that the user opened you can just close the window you opened firefox not allow that because of security reasons take a look at this: http://support.mozilla.com/en-US/questions/749393
however that's work with IE
hope it helped
Try this one (Working in Chrome & IE) -
function closeWindow() {
window.open('', '_self', '');
window.close();
}
精彩评论