Reputation: 287
Is it possible to close browsers, using JavaScript, PHP, or HTML without a prompt?
I was using this answer: How can I close a browser window without receiving the "Do you want to close this window" prompt?
I was using Internet Explorer but it has since been updated to version 10 (soon to be updated to 11) and this exploit does not work.
If there is a solution in a different (but updated) browser, that could work as well.
Upvotes: 15
Views: 7353
Reputation: 12824
There are different hacks for different browsers. This code is based on the one here with a small adjustment to the last else
block to work on IE 11. I suggest you test it on other IE versions and see if it needs more tweaking.
function closeWindow() {
var Browser = navigator.appName;
var indexB = Browser.indexOf('Explorer');
if (indexB > 0) {
var indexV = navigator.userAgent.indexOf('MSIE') + 5;
var Version = navigator.userAgent.substring(indexV, indexV + 1);
if (Version >= 7) {
window.open('', '_self', '');
window.close();
}
else if (Version == 6) {
window.opener = null;
window.close();
}
else {
window.opener = '';
window.close();
}
}
else {
window.open('', '_self', '');
window.close();
}
}
Upvotes: 0
Reputation: 139
Imagine visiting a web site that closed your browser and you lost all of your open tabs.
Upvotes: 12