Detecting browsers that are not supported by jQuery (2)

后端 未结 2 833
星月不相逢
星月不相逢 2021-02-05 11:50

Forgive me if there is an obvious answer to this question, but I haven\'t been able to find it. I am considering switching over to jQuery 2 and, although I\'m not concerned abou

2条回答
  •  一生所求
    2021-02-05 12:22

    It looks like it just drops support for IE 6, 7 and 8 - you should be able to use:

    HTML:

    
      
    

    JS:

    if( document.documentElement.getAttribute('data-browser') !== null ){
        // not supported by jQuery 2.x
    }
    

    If you decide to support older browsers but still want the improvements the jQuery team have included in 2.x then you can use the 1.x version: http://jquery.com/download/

    Update:

    It's difficult/impractical to detect every browser that doesn't support jQuery, the reason is that jQuery is just a javascript library.

    Different browsers and versions used to use different methods to do some basic things in javascript (like ajax), this means that some old browsers will support some features and won't support others. There isn't a straight forward this browser supports all features or this browser doesn't support any features test.

    Rob W's suggestion is really good, serve the new version (2.x) to modern browsers and 1.x version (with legacy support) to old browsers.

    Have a look at this article: Graceful degradation versus progressive enhancement and consider using the Modernizr library. This lets you to check which features the user's browser supports and allows you to write your applications to take full advantage of the latest advancements while still providing a good experience for users of older browsers.

提交回复
热议问题