显示目录

JS 关闭当前标签页

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function closeWindow() {
var browserName = navigator.appName;
var browserVer = parseInt(navigator.appVersion);
if (browserName == "Microsoft Internet Explorer") {
var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
if (ie7) {
// This method is required to close a window without any prompt for IE7 & greater versions.
window.open('', '_parent', '');
window.close();
} else {
// This method is required to close a window without any prompt for IE6
this.focus();
self.opener = this;
self.close();
}
} else {
// For NON-IE Browsers except Firefox which doesnt support Auto Close
try {
this.focus();
self.opener = this;
self.close();
} catch (e) {
}
// For Firefox
try {
window.location.replace("about:blank");
} catch (e) {
}
}
}