As I need JavaScript / jQuery code for closing browser's ( FireFox / Chrome and IE..)
As I have try with
window.close()
开发者_Go百科.
But it only work for IE.
Is any other way..?
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>
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;
}
I don't think that is possible as javascript can only interact with the pages rendered by the browser, not the actual browser.
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)
Try this snippet
window.close()
精彩评论