简体   繁体   English

如果客户端使用移动浏览器,如何在perl中检测?

[英]How to detect in perl if the client is using a mobile browser?

I'm using a CGI script to generate a dynamic webpage. 我正在使用CGI脚本生成动态网页。 I want the page to load elements differently depending on whether or not the user is using a phone (such as a blackberry) to access the website or a normal browser. 我希望页面以不同方式加载元素,具体取决于用户是否使用手机(如黑莓手机)访问网站或普通浏览器。 Is there an environment detail I can grab to make this decision? 是否有我可以抓住的环境细节来做出这个决定? What would be the best method of doing this (even if its using javascript and not CGI.) 这样做的最佳方法是什么(即使它使用的是javascript而不是CGI。)

Use the Perl variable $ENV{'HTTP_USER_AGENT'} and the HTTP::BrowserDetect module. 使用Perl变量$ENV{'HTTP_USER_AGENT'}HTTP :: BrowserDetect模块。

Once you have the determined what browser the client is using (eg is it a mobile browser) - then you can make the decision on what to send back to the client (mobile version or desktop version etc) 一旦确定了客户端使用的浏览器(例如,它是移动浏览器) - 那么您可以决定将什么发送回客户端(移动版或桌面版等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM