close tab window browser after change page

21
October 11, 2018, at 6:10 PM

I want to use a button in a desktop app that will close the current browser tab. the script works fine if I have opened that page for the first time, but isn't working I use it in a second page.

Example: I open a new tab with the homepage. Then, from there, I navigate on another page where there's the exit button. Here i want the people to be able to exit but they can't. Esle, if I open directly the second page the button works fine closing the tab correctly.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
 
 
 
<a href="javascript:closeWindow();">Close Window</a> 
 
 
 
 
 
 
<script> 
    function closeWindow() { 
        window.open('','_parent',''); 
        window.close(); 
    } 
</script>

anyone knows hot to fix it?

Answer 1

Hope this will help:

function closeWindow() { 
    window.open('', '_blank'); 
    window.close(); 
}
<button onclick="closeWindow()"> Close</div> 
<script src="js.js"></script>

READ ALSO
Laravel Unit test login of inactive user

Laravel Unit test login of inactive user

I would like to test the case when a user is marked as inactive in db, here is the method in LoginController

29
can not login when i add login with mobile functionality php

can not login when i add login with mobile functionality php

i have a login form in which user can login through mobile number or email or username now when i login through mobile number it works fine but when i login through username or email it says invalid how to make it works and when i remove the query for mobile...

46
Not found nagios index page

Not found nagios index page

I have installed Nagios on server following manual: http://linuxcallingblogspot

56