0

I know this question have already been asked. BUT NONE of this,this, this,this,this or this solutions worked for me. I'm only using HTML / CSS / JS for the moment on my website. Later this should run on an apache or IIS server.

Situation : On my website I wish user to access different servers. I got a html select with a lot of choice. Once they made their choice and click on connection button I check the choice they made and open it (it's a web interface like 127.0.0.1) in a new tab the link.

Problem : Some of the servers should not being accesssed if one is already used. Example : If 127.0.0.1 is used by someone, no one should access 128.0.0.1 or 129.0.0.1

The solution I found was creating a file when someone access 127.0.0.1. So when someone want to access 128.0.0.1 or 129.0.0.1, I check if the file exists. If it does exists I don't open the link and show an alert, if it does not exist I create it and open the link in new tab.

Another problem : How can I know when the tab will be closed in order to delete the file ? Have you got another solution to this problem ?

Thx in advance for helping me, I'm just a beginner in web. No solutions worked for me so far ...

Community
  • 1
  • 1
Herolex
  • 1
  • 1
  • 3
  • Please add in text *and* add tags what webserver (IIS, Apache, etc) and what web framework (ASP.NET, MVC, PHP, JSP, etc) you are using. Even if it is possible to do what you want, any solution will for the most part depend on what you are using. – Peter B Jan 09 '17 at 11:44

1 Answers1

0

This code help you to detect when user close a tab.

<script>
   window.onbeforeunload = function () {

     //write your code here 

     return false;
   };
<script>
  • Thx for help but unfortunately, this doesn't work on my PC, and I'm supposed to check if someone disconnected from an interface in a new tab. – Herolex Jan 09 '17 at 12:51
  • Well you can attach an event handler to the tab that fires when the tab is closed – Nadir Latif Jan 11 '17 at 07:00