I have several sites that I access on both my iPhone and desktop, so I like to have quick access to them via the Bookmarks Bar. However, these sites have different versions for the desktop, for mobiles, and, in some cases, yet another version for the iPhone. Usually, the full version doesn't work so well on the iPhone, and the iPhone version is undesirable on the desktop.
Instead of creating a plain bookmark, a little Javascript can make a bookmark context-sensitive, and allow you to have one bookmark that opens the right version of a page, depending on which platform you're browsing from. The basic idea is to use some client-side Javascript to check the browser's platform (a.k.a. operating system), and then tell the browser to access a URL based on that check.
The code looks like this:
javascript:if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))){location.href='URL1'}else{location.href='URL2'}javascript:if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))){location.href='http://www.google.com/m/translate?hl=en&source=mobilesearchapp'}else{location.href='http://translate.google.com/#auto|en'}Mac OS X Hints
http://hints.macworld.com/article.php?story=20100308060401535