The jQuery Browser Plugin is an addon for jQuery that makes it easy to uniquely identify your visitors' browsers.
It gives you an object in javascript that contains all of the information about the browser being used. It also adds CSS browser selectors, which means you can style elements or write functions for specific browsers, browser versions, layouts, layout versions, and even operating systems. Image of the jQuery Browser Plugin in action.
First, it quickly and carefully collects all of the information about the browser. Then, it takes all of that information and places it into intuitively named objects inside jQuery.browser, jQuery.layout, and jQuery.os. making browser information as easily accessible as jQuery already makes writing javascript.
jQuery is a small but power-packed bundle of javascript functions that make writing javascript quick and simple. Selecting elements on your page is like using CSS, learning and using functions requires minimal fuss, and the learning curve is sometimes described as "zero".
I know, right?
The jQuery Browser Plugin strives to make accessing your visitors' browser information simple and intuitive. It can literally be this simple:
alert($.browser.name); // this will alert ''
alert($.browser.version); // this will alert ''
alert($.browser.versionNumber); // this will alert '' alert($.browser.versionNumber + 1); // this will alert ''
alert($.browser.versionX); // this will alert ''
alert($.browser.className); // this will alert ''
alert($.layout.name); // this will alert ''
alert($.layout.version); // this will alert ''
alert($.layout.versionNumber); // this will alert '' alert($.layout.versionNumber + 1); // this will alert ''
alert($.layout.versionX); // this will alert ''
alert($.layout.className); // this will alert ''
alert($.os.name); // this will alert ''
Other values that may appears (this is actually based off the browser you're currently viewing this page with).
In this example, we change the color of a div based on the browser, and then add some text about the browser.
<style type="text/css"> #browsername { color: #fff; padding: 10px; text-transform: capitalize; } .firefox #browsername, .chrome #browsername { background: #f00; } .chrome #browsername { background: #357; } .msie #browsername { background: #00f; } .safari #browsername { background: #0f0; } .opera #browsername { background: #000; } .iphone #browsername { background: #ccc; color: #000; } </style> <div id="browsername"> <script>document.write($.browser.name + ' browser ' + $.browser.versionX + 'x' + '.');</script> <script>document.write($.layout.name + ' layout engine ' + $.layout.version + '.');</script> </div>
There are no known issues anymore, but don't fret, that NEVER lasts long. Know this, not ALL browsers are detected.
jQuery Browser Plugin uses a dual MIT/GPL license.
Copyright (c) 2008 Jonathan Neal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jQuery Browser Plugin by Jonathan Neal
Copyright (C) 2008 Jonathan Neal
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.