Just Beyond The Bridge

A couple of days ago Si (@Si) and I spent a few hours in a mobile workshop with Dan Rubin (@danrubin).

During the break Si and I discussed a few updates we’d like to make on our Formula One season calendar, F1Calendar.com, and try out some of the new stuff we’d learnt. Over the past day or so, I’ve spent a little time making some minor (purely iPhone/iPod Touch/iPad) improvements for those who want to use them.

However we struck a problem when saving the site to the homescreen. I’d noticed that by default, Apple handhelds use the full page title to label the icon it creates - very good for search engines, bad for users of the iPhone. As a user, it can be very fiddly to shorten it down.

I couldn’t find anything on Google (though I didn’t look too hard), but it occurred to me that back in the bad old days, it was entirely normal to see horrific animations going on in the title bar, and wondered if a bit of JS couldn’t do the job of shortening it down for mobile users - and indeed it can.

One line of code that sniffs the user agent can alter the page title. It doesn’t affect desktop browsing users or people on other mobile devices, but just is a nice touch for the users of Apple touch devices.

<script type="text/javascript">
  if( navigator.userAgent.match(/iPhone/i) || 
      navigator.userAgent.match(/iPod/i) || 
      navigator.userAgent.match(/iPad/i)
    ) {
         document.title = "F1 Calendar";
      }
</script>

Schimples. (There was an earlier error in this code - some extra parenthesis - this has now been rectified.)

I’ve guessed the iPad string there; if that’s wrong let me know, but the other two will work for sure. A nice touch for any site you imagine will be used this way.

And so now, when you visit F1 Calendar on your iPhone, not only will you get a better handheld experience than before, you’ll also have a nice, short title to use immediately, whilst it won’t compromise the search engine performance.

Try adding F1Calendar.com to your homescreen and see the result.

Update: You might want to use this alternative version for a more robust future-proof version (basing the search on the browser rather than the device). It depends on your application. (Thanks Edd)

<script type="text/javascript">
  if( navigator.userAgent.match(/Mobile/i) && 
      navigator.userAgent.match(/Safari/i)
    ) {
         document.title = "F1 Calendar";
      }
</script>

Comments (7)

This is Just Beyond The Bridge

Something About Me

Called Andy, I am passionate about design, love to travel, and have a knack for all things digital. This is the full story…

February 2012
M T W T F S S
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29        

More Stuff

Back Catalogue

  1. Dec ‘11
  2. Oct ‘11
  3. Aug ‘11
  4. Nov ‘10
  5. Apr ‘10
  6. Jan ‘10
  7. Oct ‘09
  8. Sep ‘09
  9. Aug ‘09
  10. Jul ‘09
  11. Jun ‘09
  12. Apr ‘09
  13. Mar ‘09
  14. Feb ‘09
  15. Jan ‘09
  16. Dec ‘08
  17. Nov ‘08
  18. Oct ‘08
  19. Sep ‘08
  20. Aug ‘08
  21. Jul ‘08
  22. Jun ‘08
  23. May ‘08
  24. Apr ‘08
  25. Mar ‘08
  26. Feb ‘08
  27. Jan ‘08
  28. Dec ‘07
  29. Nov ‘07
  30. Oct ‘07
  31. Sep ‘07
  32. Aug ‘07
  33. Jul ‘07
  34. Jun ‘07
  35. May ‘07
  36. Apr ‘07
  37. Mar ‘07
  38. Feb ‘07
  39. Jan ‘07
  40. Dec ‘06
  41. Nov ‘06
  42. Oct ‘06
  43. Sep ‘06
  44. Aug ‘06
  45. Jul ‘06
  46. Jun ‘06
  47. May ‘06
  48. Apr ‘06
  49. Mar ‘06
  50. Feb ‘06
  51. Jan ‘06
  52. Dec ‘05
  53. Nov ‘05
  54. Oct ‘05
  55. Sep ‘05
  56. Aug ‘05
  57. Jul ‘05
  58. Jun ‘05
  59. May ‘05
  60. Apr ‘05
  61. All Archives

Search