cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
391
Views
0
Helpful
5
Replies

Logout Agent if accidentally close browser

smeegada1
Spotlight
Spotlight

I am using beforeunload function and below code works fine if agent accidentally close browser but same code is executing if agent is trying to logout using sign-out button.Does any one have idea how i can skip this logic if agent try to logout in normal way.

    $(window).on('beforeunload', function () {           

           return "You cant close the browser without going to NOT_READY and then LOGOUT!";

           rc = { id: '28' };

           user.logout(rc, {

               success: makeCallSuccess,

               error: makeCallError

           });

        });

Any help is really appreciated.

5 Replies 5

dekwan
Cisco Employee
Cisco Employee

Hi,

Maybe you can do an agent state check within that function? Depending on when that function is called, that the agent state is LOGOUT?

Thanx,

Denise

Thanks Denise.I tried below code just to check whether we get alert when we click on SIGN-OUT dropdown but no luck.Do you know why?

  if (user.getState() == "LOGOUT") {

  alert("In LOGOUT");

Hi,

The code looks fine. Maybe the agent state isn't actually LOGOUT. I am not sure when the beforeunload function gets called. You should use the browser's developers tool to see what the agent state is in that function.

Thanx,

Denise

Hi Denise,

I did try above scenario and when agent click Logout/Sign Out on right top, agentstate is still NOT_REEADY and nothing like 'LogOut' to check condition in my code.Any idea?

Hi,

I don't think there is a way then. Checking the state is the only thing I can think of, but it seems from your testing that no matter if you click the X or the logout button, the agent is in NOT_READY state when the beforeunload is called.

Thanx,

Denise