如何检查电话浏览器或PC浏览器是否访问了网页? [英] How to check if the web page is visited by a phone browser or a PC browser?
本文介绍了如何检查电话浏览器或PC浏览器是否访问了网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查网页是否已通过移动浏览器或计算机浏览器打开.我尝试了这个:
How to check if a web page has been opened by a mobile browser or a computer browser. I tried this :
name = request.getHeader("User-Agent");
但是它给出了这类结果:
But it gives these type of results :
- 对于Fedora Firefox浏览器: Mozilla/5.0(X11; Linux i686; rv:13.0)Gecko/20100101 Firefox/13.0
- 对于Android手机浏览器: Mozilla/5.0(Linux; U; Android 2.3.6; en-in; Micromax A50 Build/GRK395)AppleWebKit/533.1(KHTML,like Gecko)Version/4.0 Mobile Safari/533.1
- For Fedora Firefox Browser : Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0
- For Android Phone Browser : Mozilla/5.0 (Linux;U;Android 2.3.6;en-in;Micromax A50 Build/GRK395) AppleWebKit/533.1(KHTML,like Gecko) Version/4.0 Mobile Safari/533.1
我不能从以上两个结果来区分是通过手机还是通过计算机访问了网页.我该怎么办?
I cannot from the above two results,differentiate whether the web page was visited by a mobile phone or a computer. How do I do that ?
如果我能在 Java 中做到这一点,那就太好了.
It will be great if I am able do this in Java.
推荐答案
就像Mikko所写的那样,没有简单的方法来检测移动设备.
Like Mikko wrote, no simple ways to detect mobile.
但是您可以尝试: http://code.google.com/p/php-mobile-detect/
和以前的答案类似: http://detectmobilebrowsers.com/
And something like previous answer: http://detectmobilebrowsers.com/
这篇关于如何检查电话浏览器或PC浏览器是否访问了网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文