Sponsors

 

Friday, August 17, 2007

Detecting an iPhone Server-Side in ColdFusion

For those rare birds who do there server sided scripting in ColdFusion or ColdFusion MX, here is a snipet of code to determine if your user's coming to the site on an iPhone:

<cfset sInfo="You are NOT using an iPhone.. Bah!">
<cfif Find("iphone;",LCase(CGI.ALL_HTTP)) GT 0>
   <cfset sInfo="Hurray! You are using an iPhone!">
</cfif>

<cfoutput><html>
<body>
<center>
     <h2>#sInfo#</h2>
</center>
</body></html>
</cfoutput>

Temperary spot for my test page: http://chomer.com/iphone/games/icheck.cfm


Run it on your iPhone, then run it on something else!

3 comments:

  1. hi any idea from detect blackberry and nokia movil? in this option (Find)

    thanks

    ReplyDelete
  2. Sorry, I've never worked with those devices before. One thing that you could do is create a simple ColdFusion web page that displays the contents of CGI.ALL_HTTP:

    #CGI.ALL_HTTP#

    , go to it from device and see what comes up!

    ReplyDelete
  3. Fantastic! congratulations for your work and ideas.
    ColdFusion Downloads

    ReplyDelete

Note: Only a member of this blog may post a comment.