1

I am facing the problem described in this post. Suggested solution doesn't suit me because I am using some jQuery history/back button plugin.

I decided to split css into to versions - one for desktop browsers (with hover features) and other for mobile ones. So I started to check if the browser's user agent header contains Mobile word. As I know only Opera doesn't append that word and uses Mini.

Is that correct way if I want to handle most iOS/Android devices?

Thank you

Community
  • 1
  • 1
nKognito
  • 6,297
  • 17
  • 77
  • 138

2 Answers2

1

I know your question was not specifically intended for Ruby on Rails but I can share with you the code I'm using to identify mobile requests. It is pretty much checking the User Agent header for Mobile or Mini existence:

  def is_mobile_request?
    request.headers.select{ |k,v| k[/AGENT/]}.values.first[/mobile|mini/i]
  end

Didn't have any problems with it so far.

Erez Rabih
  • 15,562
  • 3
  • 47
  • 64
1

You can also use the code snippet provided at detectmobilebrowsers.com. They provide mobile browser detection code for common languages used for web sites.

tilo
  • 14,009
  • 6
  • 68
  • 85