Use jQuery To Detect What Browser Your Users Are Using

jQuery has the ability to identify what browser your users are using to visit your site.  It may be more useful to use CSS conditional comments to detect a browser, jQuery makes it very easy:


if( $.browser.safari ) {
  alert('You are using Safari');
} else if( $.browser.msie && $.browser.version > 6 ) {
  alert('You are using a modern version of Internet Explorer');
} else if( $.browser.msie && $.browser.version <= 6 ) {   alert('You really really need to upgrade your browser'); } else if( $.browser.mozilla && $.browser.version >= "1.8" ) {
  alert('You are using Firefox version greater than 1.8');
}

Save Your Bandwidth! Let Google Host Your jQuery Library

It may not be widely known, but Google has been hosting several JavaScript libraries on Google Code and jQuery is one of those libraries. This has a few different advantages to allowing Google to host this file for you including:

  • It is hosted on Google.  Your bandwidth is not taken up by loading the library
  • Google can probably serve us the file faster than your server.  Especially if you are on a shared hosting solution
  • If your user has been to a site that uses the library from Google, they have already cached it.

Using the Google’s library is incredibly simple.  All you have to do is use the following code to include the jQuery library from Google:

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js”></script>

iPhone Style Checkboxes with jQuery

With the popularity of the iPhone, many plugins exist to replicate the functionality of the iPhone operating system.

Today I will talk about a plugin I stumbled upon. It replaces all checkboxes with a checkbox that is styled to match the iPhone.

I have put together a very basic demo of this plugin. You may view it here.

You can download this plugin from http://awardwinningfjords.com/2009/06/16/iphone-style-checkboxes.html

The jQuery Class

Before we have any major discussion about jQuery it is important that one understand how it works. A lot of your jQuery code will use the jQuery class. You can use the jQuery class two different ways.

jQuery('#dom') – Full text way to use jQuery. You will only use this if the shorthand functionality is already being used by another library.

$('#dom') – Shorthand way to use jQuery. Does the same as above but is significantly shorter.

Very short and quick tutorial but this is one of the most important concepts that you understand in order to be successful with jQuery.