I have a logout event in my site and once the user clicks on logout they cookies are cleared and I also display a link to close the page or the browser if the user wants.
The link id to close the browser is closeBrowser
Here is my jQuery
code
$(document).ready(function() {
$('#closeBrowser').click(function(){
window.close();
});
});
I think it is not working because the page was not opened with window.open() event
. However, I am not sure.
How can I close the page once the user clicks on that link??
Thanks
The documentation for window.close()
states :
This method is only allowed to be called for windows that were opened by a script using the window.open method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.