Reputation: 6268
As I need JavaScript / jQuery code for closing browser's ( FireFox / Chrome and IE..)
As I have try with
window.close()
.
But it only work for IE.
Is any other way..?
Upvotes: 2
Views: 26220
Reputation: 6268
Can check Browser and write respective script for IE / FireFox
IE---->
window.close()
FireFox --->
var answer = confirm("Do you want to close this window ?");
if (answer){
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
window.close();
}
else{
stop;
}
Upvotes: 3
Reputation: 51
This worked for IE and Chrome. (window.close() worked for IE, then win.close for chrome)
<script type="text/javascript">
function CloseThis() {
var win = window.open('', '_self');
window.close();
win.close(); return false;
}
</script>
Upvotes: 5
Reputation: 1607
Windows can only be closed by scripts (window.close()) that were opened by scripts in the first place. So generally, this isn't possible (https://developer.mozilla.org/en/DOM/window.close)
Upvotes: 2
Reputation: 41533
I don't think that is possible as javascript can only interact with the pages rendered by the browser, not the actual browser.
Upvotes: 2