0

it seems that the window.focus event does not trigger in Chrome.

 jQuery(window).focus(function () {
    //your logic
});

It works on both IE and FF. I read somewhere that blur may be an alternative for this in Chrome. If thats true, how do I make sure it runs only for Chrome. I don't want this logic to run twice on both IE and FF.

Update: Based on one anwser below, I can probably detect the browser, but it still does not seem to work with the blur event. Anyone knows what I can use in chrome corresponding to the focus event?

2 Answers 2

0

Read this post it will show you how tell which browser the user is using:

Distinguish Chrome from Safari using jQuery.browser

If a problem is in chrome then in most cases it's a webkit problem (safari aswell) so you could do a condition to check the browser:

 if ($.browser.webkit) {
    //webkit code here
 } else {
    //normal code here
 }
0
jQuery(window).bind('focus', function () {
    // your logic .
});

if you use bind, it seems to work fine in chrome as well. I'm using this in a modalpopupcontainer which makes it more complex. Anyway, it is working now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.