i开发者_JAVA技巧t 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?
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
 }
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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论