是否有“轨道"?重定向的方式,如果检测到移动浏览器? [英] is there a "rails" way to redirect if mobile browser is detected?
本文介绍了是否有“轨道"?重定向的方式,如果检测到移动浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想运行用户代理检查,但仅在我的主页(static_controller#home)上,我仔细查看了以下代码:
I want to run a user-agent check but only on my homepage (static_controller#home) I have taken a close look at the code: http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens and it seems close but it never gets tied together, its just method creation... I am open to a jquery method but would prefer ruby/rails over js.
我只真正关心iphone和droid ...
I only really care about iphone and droid...
推荐答案
Check out this screencast. They suggest using the following for detecting a mobile device:
request.user_agent =~ /Mobile|webOS/
这篇关于是否有“轨道"?重定向的方式,如果检测到移动浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文