冷融合移动检测

发布于 2024-12-07 17:43:33 字数 304 浏览 0 评论 0 原文

有没有办法仅使用 Coldfusion 来检测用户是否在移动设备上?

  1. 我没有进行移动重定向。
  2. 我正在使用 CSS 媒体查询来更改布局以适应屏幕宽度。
  3. 我只想做一个简单的操作,如果移动设备呈现此信息,否则将此信息呈现到网站的部分而不是整个网站。 (例如:如果移动[显示jquery动画],否则显示[链接]
  4. 我不想浪费时间渲染两者,如果只是对无论如何都不会显示的信息进行显示。
  5. 没有 javascript 移动检测(人们可能在浏览器上关闭了 javascript)

Is there a way to detection if a user is on a mobile device using just coldfusion only?

  1. I'm not doing a mobile redirect.
  2. I am using CSS media queries to change the layout to fit screen width.
  3. I just want to do a simple if mobile render this information else render this information instead to parts of the site not the whole thing. (ex: if mobile [show jquery animation] else show [link])
  4. I don't want to waste time rendering both if only to do a display none to the info not going to be shown anyways.
  5. No javascript mobile detection (people might have javascript off on their browsers)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

痴情 2024-12-14 17:43:33

我使用 http://detectmobilebrowsers.com/ 上的代码来执行此操作。他们使正则表达式保持最新状态。关于页面有关于平板电脑的详细信息(如果您需要的话)以及移动设备。删除 UDF 函数中的 if 以便轻松地使其与进一步的更改保持同步。

CFM版本:

<cfif reFindNoCase("android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",CGI.HTTP_USER_AGENT) GT 0 OR reFindNoCase("1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-",Left(CGI.HTTP_USER_AGENT,4)) GT 0>
   <cflocation url="http://mobile.yoururl.com">
</cfif>

I used the code up at http://detectmobilebrowsers.com/ to do this. They keep the regex pretty current. The about page there has details on tablets if you need that as well as mobile. Drop if in a UDF function in order to easily keep it up-to-date on further changes.

The CFM version:

<cfif reFindNoCase("android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",CGI.HTTP_USER_AGENT) GT 0 OR reFindNoCase("1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-",Left(CGI.HTTP_USER_AGENT,4)) GT 0>
   <cflocation url="http://mobile.yoururl.com">
</cfif>
不甘平庸 2024-12-14 17:43:33

我写了一篇关于这件事的博客文章!

http://www.mccran.co.uk/index.cfm/2010/6/4/Simple-Coldfusion-script-to-detect-if-a-user-is-on-a- Mobile-platform

<cfif findNoCase('Android', cgi.http_user_agent,1)>
<!--- relocate to Android version of the mobile site --->
<cflocation url="android/">
<cfelseif findNoCase('iPhone', cgi.http_user_agent,1)>
<!--- relocate to iphone version of the mobile site --->
<cflocation url="iphone/">
</cfif>

您可以轻松地从用户代理字符串中检测浏览器。不过,正如我最近经历的那样,像 Chrome 这样的浏览器将允许您更改用户代理字符串:

http://www.mccran.co.uk/index.cfm/2011/9/25/Samsung-Galaxy-Tab-101-Switching-your-browser-from-mobile-view

I wrote a blog entry about this very thing!

http://www.mccran.co.uk/index.cfm/2010/6/4/Simple-Coldfusion-script-to-detect-if-a-user-is-on-a-Mobile-platform

<cfif findNoCase('Android', cgi.http_user_agent,1)>
<!--- relocate to Android version of the mobile site --->
<cflocation url="android/">
<cfelseif findNoCase('iPhone', cgi.http_user_agent,1)>
<!--- relocate to iphone version of the mobile site --->
<cflocation url="iphone/">
</cfif>

You can easily detect the browser from the user agent string. Tho as I've experienced recently browsers like chrome will allow you to change your user agent string:

http://www.mccran.co.uk/index.cfm/2011/9/25/Samsung-Galaxy-Tab-101-Switching-your-browser-from-mobile-view

瞄了个咪的 2024-12-14 17:43:33

使用 CGI.HTTP_USER_AGENT:

<cfif (CGI.HTTP_USER_AGENT is "MobileAgentOne")>

将 MobileAgentOne 替换为您要查找的浏览器。

快速谷歌应该为您提供当前正在使用的移动代理的足够列表,例如:http ://www.useragentstring.com/pages/Mobile%20Browserlist/

如果您想变得更强大一点,这里有一种提供部分匹配的方法,这样您就可以寻找手机系列,而不是比列出来一百万个不同的独特移动代理:

<cfset agentList = "ASUS,AUDIOVOX,BenQ">

<cfloop list="#agentList#" index="thisAgent">
    <cfif FindNoCase(thisAgent, CGI.HTTP_USER_AGENT)>
        Found
    </cfif>
</cfloop>

Use CGI.HTTP_USER_AGENT:

<cfif (CGI.HTTP_USER_AGENT is "MobileAgentOne")>

replace MobileAgentOne with the browser you are looking for.

A quick google should provide you with an adequate list of Mobile agents currently in-use, such as: http://www.useragentstring.com/pages/Mobile%20Browserlist/

If you'd like to be a tad more robust, here's a way to provide partial matches, so you can look for families of mobile phones, rather than listing out one million different unique mobile agents:

<cfset agentList = "ASUS,AUDIOVOX,BenQ">

<cfloop list="#agentList#" index="thisAgent">
    <cfif FindNoCase(thisAgent, CGI.HTTP_USER_AGENT)>
        Found
    </cfif>
</cfloop>
皓月长歌 2024-12-14 17:43:33

您可以检查CGI.HTTP_USER_AGENT的值,看看它是否表明客户端是移动设备。

以下是基于我找到的一些 Python 代码的快速片段,但您可能可以执行更高级的检查:

<cfif refindNoCase
    ( 'android|blackberry|iphone|ipod|mobile|palm|phone|windows\s+ce'
    , CGI.HTTP_USER_AGENT
    )>
    probably mobile
</cfif>

You can examine the value of CGI.HTTP_USER_AGENT and see if it indicates that the client is a mobile.

Here's a quick snippet based on some Python code I found but there may be more advanced checks you can do:

<cfif refindNoCase
    ( 'android|blackberry|iphone|ipod|mobile|palm|phone|windows\s+ce'
    , CGI.HTTP_USER_AGENT
    )>
    probably mobile
</cfif>
栩栩如生 2024-12-14 17:43:33

(很抱歉回答这个问题,但我无法在这里发表评论。)

对字符串“android”的测试捕获了一堆平板电脑(motorola xoom、三星 Galaxy Tab、华硕 Transformer、其他来自东芝、索尼、宏基等的平板电脑) .)。 Android 是一个操作系统,而不是一类设备。

我想说,一个现实的答案很大程度上取决于您所认为的“移动”设备。可以说,考虑到许多平板电脑的处理能力和物理屏幕尺寸,许多平板电脑在“普通”(非移动)网站上表现得很好,因此将它们与更小、功能更弱的手机混在一起对这些用户来说是一个disservice

请注意,之前的几个答案中列出了“iPhone”,但没有列出“iPad”,因此它们隐式排除了 iOS 平板电脑,我相信这对于 Android 来说也是正确的。

不幸的是,基于这种方法的答案并不那么简单。网上有各种解决方案,其中一个基本版本是查找“mobile”一词并排除一些特定于平板电脑的字符串,例如tablet、pad、xoom、eeepc、flyer等。但是,每周都会出现新设备,即使是追逐最流行的设备也将是一个挑战。

(Apologies for making this an answer, but I'm unable to comment here.)

Testing for the string 'android' catches a bunch of tablets (motorola xoom, samsung galaxy tab, asus transformer, others from toshiba, sony, acer, etc.). Android is an OS, not a class of devices.

I'd say a realistic answer depends a lot on what you consider to be a "mobile" device. Arguably, many tablets do just fine with "normal" (non-mobile) sites, given their processing power and physical screen size, so lumping them in with much smaller and less capable mobile phones does those users a disservice.

Note that 'iPhone' is listed in several previous answers, but not 'iPad', so they implicitly exclude iOS tablets, which I believe is correct for android too.

An answer based on that approach is much less trivial, unfortunately. Various solutions are out there on the net, one basic version of which is to look for the word mobile and exclude some tablet-specific strings such as tablet, pad, xoom, eeepc, flyer, etc. However, new devices appear every week, and chasing even the most popular ones will be a challenge at best.

開玄 2024-12-14 17:43:33

detectormobilebrowsers.com 解决方案是否位于标题中?有什么理由不把检测线放在表头之前吗?我有一个框架集(我知道,不理想......),我认为框架集首先被检测到并在运行检测脚本运行之前加载我的框架。 (这可能吗?)
它在 android 的标题中工作正常,但在 kindle、ipad 或 iphone 上则不行(我添加了一条 ipad 行)。

感谢您的阅读,
LPP

Does the detectmobilebrowsers.com solution go in the header? Is there any reason not to put the detection line before the header? I have a frameset (I know, not ideal...) and I think the frameset is getting detected first and loading my frames before running the detection script runs. (Is that possible?)
It works fine in the header with android, but not kindle, ipad or iphone (I added an ipad line).

Thanks for reading,
LPP

‘画卷フ 2024-12-14 17:43:33

(很抱歉回答而不是评论,我无法评论或投票)

我最初喜欢 mujimu 的解决方案。我把它放在我的网站上,用我自己的 iPhone 进行测试似乎效果很好。但是,我开始用这个 http://www.mobilephoneemulator.com/ 进行测试,但它不起作用大多数设备。

这就是我会做的(并且将会做的)。在一个谨慎的位置输出类似的内容#CGI.HTTP_USER_AGENT#。然后测试并记录设备的输出内容。

然后,使用类似的东西(谢谢 Peter Boughton),并在管道之间,使用测试中的不同关键字...

<cfif refindNoCase
    ( 'distinct_keyword|android|blackberry|iphone|ipod|mobile|palm|phone|windows\s+ce'
    , CGI.HTTP_USER_AGENT
    )>
    probably mobile
</cfif>

经过我的初步测试,这是我列出的列表。如果您认为这是准确的,请告诉我...

ARCELIK、Access、Acer、Ahong、Aiko、Airis、Airness、Alcatel、AlphaCell Wireless、Amazon、Amoi、Amoisonic、Android、AnexTek、Apple、Archos、Asmobile、Aspen、华硕,华硕电脑INC.、Audiovox、Becker、BEKO、Bellawave、BellWave、BenQ、明基西门子、明基西门子、Bird、Bleu、Blue Coat、B-Mobile、Bolt、Bytemobile、首信、卡西欧、CDM、CECT、CheckCom、Cingular、Cking、仁宝、康柏、CoralWeb、Cricket、Dai电信、Dallab、Danger、大显、DBTEL、Dicam、Dmobo、DoCoMo、Dopod、Doris、DreamPhone、EDL、Elite、ELSON、Emblaze、Emobile、Enteos、Era、Ericsson、Ericy、ETEN、EZIO、EZZE、Fitel、Fly、富士通、通用、通用网络浏览器、通用 Windows、通用 Windows手机、技嘉、金立、Google、Gradiente、根德、海尔、Handspring、七喜、黑海、Helio、惠普、海信、日立、HP、HTC、HTC Corporation、HTIL、华为、悍马、IAC OKWAP、IAC OKWAP Mobile通信、Idea、iKoMo、IM、Imate、i-mate、i-mobile、英飞凌、InfoSonics、Innostream、INQ Mobile、Itelco、IXI、KCM、KDDI、KDDI -索尼爱立信、KDDI-卡西欧、KDDI-日立、KDDI-京瓷、KDDI-京瓷、KDDI-松下、KDDI-泛泰、KDDI-三洋、KDDI-夏尔p,KDDI-索尼爱立信,KDDI-索尼爱立信,KDDI-东芝,科健,凯森,克朗代克,康佳,科子,KPT,K-Touch,京瓷,京瓷Wireless Corp、LCT、联想、联想移动、Lexibook、雷克萨斯、LG、LG Electronics、LGE、Lobster、Longcos、LT、LXE、M3 Gate、Malata、基于 MAUI 的 Generic、Maxon、Medion、MicroMax、Microsoft、MIO、Mio科技、Miracle、神达、三菱、移动无线集团、MOBISTEL、Modelabs、ModelLabs、Modottel、Modu、MOMO设计、Morange、摩托罗拉、Myphone、NEC、Neonode、Newgen、Nexian、任天堂、诺基亚、Novarra、NTT DoCoMo、NTT DoCoMo FOMA 3G、O2、ONDA、Openwave、Opera、Optimay、Orange、Palm、PalmOne、松下、Panda、 Pantech、PCD、飞利浦、PhoneOne、倍耐力-Arcor、保时捷Design、Porshe、Poseidon、Psion、QCI、QMobile、Qtek、Raks、Reporo、Research In Motion Ltd.、RIM、Robot、Ron、Rover、RT、Sagem、SAMART、三星、三洋、SavaJe、SEC、Semc、Sendo、夏普、西门子、天火、Skyspring、Skyspring Vitelcom、创维、SKYZEN、SlobTrot软件、SmartTrust、Smile、软银、Sonim、索尼、索尼爱立信移动通信、索尼爱立信、Spice、Sprint、SPV、Sunrise、TCL、德信、T​​el.Me.、意大利电信、泰利特、天宇、T-Mobile、Toplux、东芝,Tranxcode,TTPCom,tvCompass,tvCompass DMR1500、Ubiquam、UCWEB、Uniscope、Unistar、Uriver、Usha Lexus、Utec、UTStarcom、V3m (Metro PCS)、Vacom、Velocity Mobile、Venera、Verizon、Vertu、VeryKool、VERZIOWORLD、Vitelcom、VITELCOM for Telefonica Movistar、VK、VK移动,沃达丰,沃达丰中兴、Voxtel、W3C、Wapamp、Wapsilon、WAPUniverse、WellcoM、WinWAP Technologies、Wonu、XDA、Yas、Yospace 爱立信、Yospace 摩托罗拉、Yospace 诺基亚、Yospace 夏普、Yospace 西门子、Yospace 索尼爱立信、宇龙、中大、ZT、中兴、。手机

(Sorry for answering instead of commenting, I'm not able to comment or vote up)

I initially liked mujimu's solution. I put it on my site and it seemed to work well testing with my own iphone. However, I started testing with this http://www.mobilephoneemulator.com/ and it didn't work for a majority of devices.

Here's what I would do (and will do). Output something like this in a discreet location <cfoutput>#CGI.HTTP_USER_AGENT#</cfoutput>. Then test and record what the devices output.

Then, use something like this (thank you Peter Boughton) and in between the pipes, use a distinct keyword from the testing...

<cfif refindNoCase
    ( 'distinct_keyword|android|blackberry|iphone|ipod|mobile|palm|phone|windows\s+ce'
    , CGI.HTTP_USER_AGENT
    )>
    probably mobile
</cfif>

After my initial testing here's the list I've come up with. Please let me know if you think this is accurate...

ARCELIK,Access,Acer,Ahong,Aiko,Airis,Airness,Alcatel,AlphaCell Wireless,Amazon,Amoi,Amoisonic,Android,AnexTek,Apple,Archos,Asmobile,Aspen,Asus,ASUSTeK COMPUTER INC.,Audiovox,Becker,BEKO,Bellawave,BellWave,BenQ,BenQSiemens,BenQ-Siemens,Bird,Bleu,Blue Coat,B-Mobile,Bolt,Bytemobile,Capitel,Casio,CDM,CECT,CheckCom,Cingular,Cking,Compal,Compaq,CoralWeb,Cricket,Dai Telecom,Dallab,Danger,Daxian,DBTEL,Dicam,Dmobo,DoCoMo,Dopod,Doris,DreamPhone,EDL,Elite,ELSON,Emblaze,Emobile,Enteos,Era,Ericsson,Ericy,ETEN,EZIO,EZZE,Fitel,Fly,Fujitsu,generic,generic web browser,Generic Windows,Generic Windows Mobile,GIGABYTE,Gionee,Google,Gradiente,Grundig,Haier,Handspring,Hedy,Hei,Helio,Hewlett-Packard,Hisense,Hitachi,HP,HTC,HTC Corporation,HTIL,HUAWEI,Hummer,IAC OKWAP,IAC OKWAP Mobile Communications,Idea,iKoMo,IM,Imate,i-mate,i-mobile,Infineon,InfoSonics,Innostream,INQ Mobile,Itelco,IXI,KCM,KDDI,KDDI - SonyEricsson,KDDI-Casio,KDDI-Hitachi,KDDI-Kiocera,KDDI-Kyocera,KDDI-Panasonic,KDDI-Pantech,KDDI-Sanyo,KDDI-Sharp,KDDI-SonyEriccson,KDDI-SonyEricsson,KDDI-Toshiba,Kejian,Kisen,Klondike,KONKA,Kozi,KPT,K-Touch,Kyocera,Kyocera Wireless Corp,LCT,Lenovo,Lenovo Mobile,Lexibook,Lexus,LG,LG Electronics,LGE,Lobster,Longcos,LT,LXE,M3 Gate,Malata,MAUI-based Generic,Maxon,Medion,MicroMax,Microsoft,MIO,Mio Technology,Miracle,MiTAC,Mitsubishi,Mobile Wireless Group,MOBISTEL,Modelabs,ModelLabs,Modottel,Modu,MOMO Design,Morange,Motorola,Myphone,NEC,Neonode,Newgen,Nexian,Nintendo,Nokia,Novarra,NTT DoCoMo,NTT DoCoMo FOMA 3G,O2,ONDA,Openwave,Opera,Optimay,Orange,Palm,PalmOne,Panasonic,Panda,Pantech,PCD,Philips,PhoneOne,Pirelli-Arcor,Porsche Design,Porshe,Poseidon,Psion,QCI,QMobile,Qtek,Raks,Reporo,Research In Motion Ltd.,RIM,Robot,Ron,Rover,RT,Sagem,SAMART,Samsung,Sanyo,SavaJe,SEC,Semc,Sendo,Sharp,Siemens,Skyfire,Skyspring,Skyspring Vitelcom,Skyworth,SKYZEN,SlobTrot Software,SmartTrust,Smile,SoftBank,Sonim,Sony,Sony Ericsson Mobile Communications,SonyEricsson,Spice,Sprint,SPV,Sunrise,TCL,Techfaith,Tel.Me.,Telecom Italia,Telit,TIANYU,T-Mobile,Toplux,Toshiba,Tranxcode,TTPCom,tvCompass,tvCompass DMR1500,Ubiquam,UCWEB,Uniscope,Unistar,Uriver,Usha Lexus,Utec,UTStarcom,V3m (Metro PCS),Vacom,Velocity Mobile,Venera,Verizon,Vertu,VeryKool,VERZIOWORLD,Vitelcom,VITELCOM for Telefonica Movistar,VK,VK Mobile,Vodafone,Vodafone ZTE,Voxtel,W3C,Wapamp,Wapsilon,WAPUniverse,WellcoM,WinWAP Technologies,Wonu,XDA,Yas,Yospace Ericsson,Yospace Motorola,Yospace Nokia,Yospace Sharp,Yospace Siemens,Yospace SonyEricsson,Yulong,Zonda,ZT,ZTE,.mobi

述情 2024-12-14 17:43:33

根据以下 JavaScript 答案,现在更好的解决方案可能是使用如下内容,这可以避免更改用户代理时出现问题。

https://stackoverflow.com/a/24600597/1427373

适用于 ColdFusion:

<cfset mobileDevice = false>

<!--- Detect if we are using a mobile device --->
<cfif reFindNoCase("Mobi|Android", CGI.HTTP_USER_AGENT) NEQ 0>
  <cfset mobileDevice = true>
</cfif>

Per the following JavaScript answer, a better solution may now be to use something like the following, which avoids issues with changing user agents.

https://stackoverflow.com/a/24600597/1427373

Adapted for ColdFusion:

<cfset mobileDevice = false>

<!--- Detect if we are using a mobile device --->
<cfif reFindNoCase("Mobi|Android", CGI.HTTP_USER_AGENT) NEQ 0>
  <cfset mobileDevice = true>
</cfif>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文