Our online blog

Posts Tagged ‘detect blackberry using coldfusion’

Detecting iPhone, Blackberry etc using ColdFusion

Sunday, March 29th, 2009

Many of our clients have been asking about detecting if a user is using a blackberry or iPhone etc to view their website and redirect to a mobile version of their websites. Well we have put together a little bit of code to do this:

Code example:

<cfif findNoCase('blackberry', CGI.HTTP_USER_AGENT)>
<cflocation url="http://blackberry.yourdomain.com" addtoken="no">
<cfelseif findNoCase('iphone', CGI.HTTP_USER_AGENT)>
<cflocation url="http://iphone.yourdomain.com" addtoken="no">
<cfelseif CGI.HTTP_ACCEPT CONTAINS "text/vnd.wap.wml">
<cflocation url="http://wap.yourdomain.com" addtoken="no">
</cfif>

Hope you enjoy this code snippet.