How to detect browser type and its version

后端 未结 5 1972
借酒劲吻你
借酒劲吻你 2021-02-03 21:54

how can i detect browser type and its version in Rails. I want to put check on the version of specific browser and if its not required browser version than ask user to upgrade i

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-03 22:36

    There is also useragent gem:

    <% user_agent = UserAgent.parse(request.env["HTTP_USER_AGENT"]) %>
    App: <%= user_agent.application %> # Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:22.0)
    Browser: <%= user_agent.browser %> # Firefox
    Version: <%= user_agent.version %> # 22.0
    Platform: <%= user_agent.platform %> # Macintosh
    Mobile: <%= user_agent.mobile? %> # False
    OS: <%= user_agent.os %> # OS X 10.8
    

提交回复
热议问题