Archive

Archive for September, 2010

Google thinking INSIDE the box.

September 8th, 2010 1 comment

All day today, my inbox has been bombarded with news articles about Google’s freshly launched ‘Instant’ search feature whereby results are returned as-you-type your search query. One particular comment by pmichner caught my attention. It reads:

So if while I’m typing “farthest” I’ll see results for fart?

Well, here’s the answer! Click this thumbnail to see what Google does.

Am I the only person wondering how long it will be before the first flaws of ‘SafeSearch’ are identified and surface? I can just picture it now, some kid typing the first few characters of a harmless search, only to have inappropriate material forced into their face.

I’ll leave that test to others, but what do you think about this new feature?

iPhone and/or iPod user agent detection with JavaScript

September 8th, 2010 1 comment

A colleague of mine sent me a piece of code which he had implemented to detect the iPhone by javascript. His code looked like this:

if((!navigator.userAgent.match(/iPhone/i))) { //step here if not iphone }

Although the code works, there is some room for improvement. And so here is what he is now using:

var agent = navigator.userAgent;
var is_iphone = (agent.match(/iPhone/i) ? true : (agent.match(/iPod/i) ? true : false));

/* the is_iphone variable is now true or false
   we can use it as many times as we like: */

if (is_iphone) {
  /* it's an iphone, do something */
}

if (!is_iphone) {
  /* this is not an iphone, do something else */
}

Much more readable too, I think.

Categories: All, Web