[RESOLVED]IE11 having issues with javascript. If i'm put alert() in my code it's working. without alert() not working in for only IE11 only all IE version working without alert()


    I doing on a big product requirement that if client close the browser need to logout from database that client. while I’m working on this I’m able to execute this function all browsers. in < IE10 versions working fine. But I’m recently upgraded
to IE11. This functionality not working in IE11 version only if I put alert() message in this code it’s working.

here’s the code

varCookieClientID =

varCookieUserID =

$(window).unload(function() {


function() {


if(beforeunloadval == 1) {

varvalue = document.cookie.split(‘|’);

CookieClientID = value[7];

CookieUserID = value[8];

if(CookieClientID !=
""|| CookieUserID !=
""|| CookieClientID != undefined || CookieUserID != undefined) {


//BTGUI.WebServices.ConnectionToken.LogoutMethod(CookieClientID, CookieUserID, LogoutMethodSucess);

if(Sys.Browser.name ==
"Microsoft Internet Explorer") {

BTGUI.WebServices.ConnectionToken.LogoutMethod(CookieClientID, CookieUserID, LogoutMethodSucess);

// without alert() not working on IE11 but working on below versions of IE versions if put alert() it’s working in IE11




BTGUI.WebServices.ConnectionToken.LogoutMethod(CookieClientID, CookieUserID, LogoutMethodSucess);



catch(e) {








What error is thrown by IE11?

You have to know that: UserAgent string has been changed in IE11, making it difficult to detect it.

check this site for details:


When you close the browser, there is no guarantee that the server side code will make success. Sometimes it works, sometimes it’s not. You are experience the outcome of a badly designed solution. We usually handle logout in the Session_End event. Do not
rely on the client side events. :)

As for it’s working when you put an alert, I believe the browser hangs on because it displays the alert so it has time to make the server call. When you close the browser, the process ends so there is no way to make the server call. It depends on how the
OS handle the exit process of the browser application I guess.

Leave a Reply