X

LATEST #JQUERY NEWS

How to Detect a Browser Using jQuery


Any developer can tell you that code will render differently depending on the browser, which can be a real hindrance to cross-browser compatibility. There are CSS hacks that can be used to determine what browser code is running on, but these can only be used to change styling, not HTML. If you want to dynamically change any HTML in your code based on the browser, you can do so using the following jQuery snippets that utilize the $.browser selector:

$(document).ready(function() {
    // For Chrome
    if ($.browser.chrome) {
        // insert your code here
    }
    // For Mozilla Firefox 
    if ($.browser.mozilla & amp; & amp; $.browser.version & gt; = "1.8") {
        // insert your code here 
    }
    // For Opera 
    if ($.browser.opera) {
        // insert your code here 
    }
    // For Safari if( $.browser.safari ) { // insert your code here }
    // For Internet Explorer versions below 6
    if ($.browser.msie & amp; & amp; $.browser.version & lt; = 6) {
        // insert your code here
    }
    // For IE versions 6+
    if ($.browser.msie & amp; & amp; $.browser.version & gt; 6) {
        // insert your code here
    }
});

Recently Published

article image
»

7 Responsive jQuery Dropdown Menu Plugins

Dropdown Menu Plugins Dropdown menus are mostly used for website ...

article image
»

20 Stylish and Modern jQuery Tooltip Plugins

jQuery Tooltip Plugins Tooltips are a great option for showing extra ...

article image
»

15 Newest jQuery plugins for responsive website

Due to the proliferation of smartphones and tablets, responsive ...

article image
»

How to use Redux with jQuery

State management is one of most integral parts of any software and a ...

article image
»

Fade HTML Table Row on Hover Using jQuery

HTML tables are the ideal choice for displaying data in tabular form. ...

article image
»

Drag and Drop HTML Table Rows Using jQuery

HTML tables are the preferred UI option for displaying data. Sorting, ...

article image
»

Top 5 Best JavaScript Template Engines

Template engines help in the decoupling of HTML and JavaScript code ...

article image
»

3 jQuery/JavaScript Plugins for Push Notifications

Push notifications started from the mobile business but this ...

article image
»

Create Smooth Animation Using jQuery’s “stop()”

Making Quick Work jQuery’s animate() method is a quick way to ...