Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts
Detecting Mobile Browsers- Applying CSS

Detecting Mobile Browsers- Applying CSS

In my previous articles on detecting mobile browsers, my scripts redirected the viewer to a mobile formatted page, such as the xfruits site I use for 2mlearn.mobi.

Greg at Brain Handles offers another suggestion, using the script to reformat a page using mobile detected CSS scripts. There are some challenges to his script, specifically for designers who aren't familiar with php scripting.

Personally, I prefer using the simpler script and having a completely customized page for mobile users. This way, you aren't just reformatting the content for mobile, but you can customize the content completely. The php script Greg offers, however, has advantages for internal users who want to reuse content that is simply reformatted instead of offering completely custom content for your viewers.

Click here to see Greg's suggested script.








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.