Mobile Browser Detection Hack

As was surely inevitable, I am now obliged to think more about the experience a user might have of a site while using mobile devices. I could have staved this off for a little while yet longer, but iOS and Android fire the mouseover event in jQuery. Why? Where's the mouse? This gets in the way with a new, mobile-friendly, dhtml menu system I'm creating - works through clicks as well as mouseovers.

Anyway, I thought to either investigate the event handling issue (maybe a jQuery issue) or go for browser detection. As there are more and more mobile initiatives rolling down the pipe for me, detection seemed like it might be more helpful. And, really, I didn't want to reinvent the wheel so I went looking for pre-existing solutions.

I found Detect Mobile Browser, an open-source tool, but it didn't think that iPad was a mobile device. In my framework speed dating session, I said goodbye quickly to the prospect of a long term relationship. I did notice, though, from the USER_AGENT that it was reporting, that all the mobile devices I was checking identified themselves as "mobile" somewhere in the string.

So, a quick hack that seems to do the trick emerged:

[More]

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner