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,147
  • 16
  • 70
  • 136

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,080
  • 3
  • 42
  • 62
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
  • 13,754
  • 6
  • 65
  • 84