Script to Detect iPhone and Blackberry

The most visited post at mLearning-World.com is my scripts for how to detect if a visitor is hitting your site with a mobile phone and redirect them to a mobile friendly version of this website (at 2mlearn.mobi).


I have received a lot of emails asking how we can modify this script to detect iPhones or Blackberry browsers. For the most part, the script is identical.



First, the original script-





With the iPhone, it is fairly simple. in your "if" string, include the following:



if((navigator.userAgent.match(/iPhone/i)) (navigator.userAgent.match(/iPod/i)))

A Blackberry is a little more challenging as you can have different browsers. For example, I am using Opera Mobile on my Blackberry Pearl. With a Blackberry, the browser detect in the first script should work, however, Opera Mobile reformats the page automatically and thus, the script shouldn't be needed.

I am currently experimenting with several other browser options. I'll add a new post as I discover more scripts to help your mobile learners.

















Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer