Differentiating the closing of the browser tab and refresh is really a pain, because we do not have two events to find out which event will be fired.
But there are always some requirements :)
What I do is set one cookie to on-load and make the flag true if it is found to be a cookie and delete the cookie in the browser close event.
So, until he closes the active tab (login), this cookie still exists, and if he tries to open on another tab, an already active dialog box will appear.
Note. A cookie provided solution Cookies.
In Here, onModule () for GWT / is the same as onload/document.ready() for java script/Jquery .
@Override public void onModuleLoad() { if("already_in_browser". equalsIgnoreCase(Cookies.getCookie("already_in_browser"))){ showAlreadyTabActiveDialog(); return; }else{ setLoggedincookie(); } private void setLoggedincookie() { isLoggedintab = true;
Let me know if you find any errors or holes in the loop in it. Therefore, I will look at them.
I would be very happy if someone provides a solution without using cookies .
source share