I have a logout button on which if user clicks, browser tab need to be closed. I have tried with the following method:
window.close();
but its not working in any of the browsers.
If you try to close any window with window.close()
you will get error message like
"Scripts may not close windows that were not opened by script"
(Message Depends on Browser)
so, its mean you must have to open windows by JavaScript first to close by your code, like:
window.open("http://www.google.com/");
now you can easily close this window by window.close()
.
.
Another advantage using this functionality is you can also close Child Window
from
Parent Windows`. like:
var win;
$('#click').click(function() {
win = window.open("test3.html", "something", "width=550,height=170");
});
function closeit() {
win.close();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With