'**************************************************
'函数名:websitez_detect_mobile_device
'作  用:判断访问浏览器的类型
'参  数:
'返回值:浏览器类型
'函数名:RegExpTest
'作  用:在正则表达式中搜索给定的字符串,找到返回 true
'参  数:
'返回值:布尔型
'日期:11-12-18
'**************************************************
Function RegExpTest(patrn, strng) 
Dim regEx, retVal '建立变量。 
Set regEx=New RegExp '建立正则表达式。 
regEx.Pattern=patrn  '设置模式。 
regEx.IgnoreCase=True '设置是否区分大小写,true为不区分。 
retVal=regEx.Test(strng) '执行搜索测试。 
RegExpTest=retVal 
End Function 
function websitez_detect_mobile_device()
  'Innocent until proven guilty
  dim mobile_browser,user_agent, accept,mobile_browser_type
  
  mobile_browser = false
  'Speaks for itself
  user_agent=Trim(Lcase(Request.ServerVariables("HTTP_USER_AGENT")))
  'This can also be used to detect a mobile device
  accept = Request.ServerVariables("HTTP_ACCEPT")
  'Type of phone
  mobile_browser_type = "0" '0 - PC, 1 - Smart Phone, 2- Standard Phone  3 touch phone
Select case true
  'Start off with smart phones or smart devices
  case InStr(user_agent,"ipod")>0 or InStr(user_agent,"iphone")>0 or InStr(user_agent,"ipad")>0'iPhone or iPod
   mobile_browser = true
   mobile_browser_type = "3" 'Smart Phone
  case InStr(user_agent,"android")>0 'Android
   mobile_browser = true
   mobile_browser_type = "3" 'Smart Phone
  case InStr(user_agent,"opera mini")>0 'Opera Mini
   mobile_browser = true
   mobile_browser_type = "1" 'Smart Phone
  case InStr(user_agent,"blackberry")>0 'Blackberry
   mobile_browser = true
   mobile_browser_type = "1" 'Smart Phone
  case InStr(user_agent,"series60")>0 or InStr(user_agent,"series 60")>0  'Symbian OS
    mobile_browser = true
    mobile_browser_type = "1"'Smart Phone
  case RegExpTest("(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)",user_agent)'Palm OS
      mobile_browser = true
   mobile_browser_type = "1"'Smart Phone
  case RegExpTest("(iris|3g_t|windows ce|opera mobi|iemobile)",user_agent)'Windows OS
      mobile_browser = true
   mobile_browser_type = "1" 'Smart Phone
  case RegExpTest("(maemo|tablet|qt embedded|com2)",user_agent)'Nokia Tablet
      mobile_browser = true
   mobile_browser_type = "1" 'Smart Device
  'Now look for standard phones & mobile devices
   
  case RegExpTest("(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo|vnd.rim|wml|nitro|nintendo|wii|xbox|archos|openweb|mini|docomo)",user_agent) 'Mix of standard phones
   mobile_browser = true
   mobile_browser_type = "2" 'Standard Phone
  case InStr(accept,"text/vnd.wap.wml")> 0 or InStr(accept,"application/vnd.wap.xhtml+xml")>0 'Any falling through the cracks
   mobile_browser = true
   mobile_browser_type = "2" 'Standard Phone
  case Request.ServerVariables("HTTP_X_WAP_PROFILE")<>"" or Request.ServerVariables("HTTP_PROFILE")<>"" 'Anyfalling through the cracks
   mobile_browser = true
   mobile_browser_type = "2" 'Standard Phone
     case ubound(filter(array("1207","3gso","4thp","501i","502i","503i","504i","505i","506i","6310","6590","770","802s","a wa","acer","acs","airn","alav","asus","attw","au-m","aur ","aus ","abac","acoo","aiko","alco","alca","amoi","anex","anny","anyw","aptu","arch","argo","bell","bird","bw-n","bw-u","beck","benq","bilb","blac","c55/","cdm-","chtm","capi","cond","craw","dall","dbte","dc-s","dica","ds-d","ds12","dait","devi","dmob","doco","dopo","el49","erk0","esl8","ez40","ez60","ez70","ezos","ezze","elai","emul","eric","ezwa","fake","fly-","fly_","g-mo","g1 u","g560","gf-5","grun","gene","go.w","good","grad","hcit","hd-m","hd-p","hd-t","hei-","hp i","hpip","hs-c","htc ","htc-","htca","htcg","htcp","htcs","htct","htc_","haie","hita","huaw","hutc","i-20","i-go","i-ma","i230","iac","iac-","iac/","ig01","im1k","inno","iris","jata","java","kddi","kgt","kgt/","kpt ","kwc-","klon","lexi","lg g","lg-a","lg-b","lg-c","lg-d","lg-f","lg-g","lg-k","lg-l","lg-m","lg-o","lg-p","lg-s","lg-t","lg-u","lg-w","lg/k","lg/l","lg/u","lg50","lg54","lge-","lge/","lynx","leno","m1-w","m3ga","m50","maui","mc01","mc21","mcca","medi","meri","mio8","mioa","mo01","mo02","mode","modo","mot ","mot-","mt50","mtp1","mtv ","mate","maxo","merc","mits","mobi","motv","mozz","n100","n101","n102","n202","n203","n300","n302","n500","n502","n505","n700","n701","n710","nec-","nem-","newg","neon","netf","noki","nzph","o2 x","o2-x","opwv","owg1","opti","oran","p800","pand","pg-1","pg-2","pg-3","pg-6","pg-8","pg-c","pg13","phil","pn-2","pt-g","palm","pana","pire","pock","pose","psio","qa-a","qc-2","qc-3","qc-5","qc-7","qc07","qc12","qc21","qc32","qc60","qci-","qwap","qtek","r380","r600","raks","rim9","rove","s55/","sage","sams","sc01","sch-","scp-","sdk/","se47","sec-","sec0","sec1","semc","sgh-","shar","sie-","sk-0","sl45","slid","smb3","smt5","sp01","sph-","spv ","spv-","sy01","samm","sany","sava","scoo","send","siem","smar","smit","soft","sony","t-mo","t218","t250","t600","t610","t618","tcl-","tdg-","telm","tim-","ts70","tsm-","tsm3","tsm5","tx-9","tagt","talk","teli","topl","hiba","up.b","upg1","utst","v400","v750","veri","vk-v","vk40","vk50","vk52","vk53","vm40","vx98","virg","vite","voda","vulc","w3c ","w3c-","wapj","wapp","wapu","wapm","wig ","wapi","wapr","wapv","wapy","wapa","waps","wapt","winc","winw","wonu","x700","xda2","xdag","yas-","your","zte-","zeto","acs-","alav","alca","amoi","aste","audi","avan","benq","bird","blac","blaz","brew","brvw","bumb","ccwa","cell","cldc","cmd-","dang","doco","eml2","eric","fetc","hipt","http","ibro","idea","ikom","inno","ipaq","jbro","jemu","java","jigs","kddi","keji","kyoc","kyok","leno","lg-c","lg-d","lg-g","lge-","libw","m-cr","maui","maxo","midp","mits","mmef","mobi","mot-","moto","mwbp","mywa","nec-","newt","nok6","noki","o2im","opwv","palm","pana","pant","pdxg","phil","play","pluc","port","prox","qtek","qwap","rozo","sage","sama","sams","sany","sch-","sec-","send","seri","sgh-","shar","sie-","siem","smal","smar","sony","sph-","symb","t-mo","teli","tim-","tosh","treo","tsm-","upg1","upsi","vk-v","voda","vx52","vx53","vx60","vx61","vx70","vx80","vx81","vx83","vx85","wap-","wapa","wapi","wapp","wapr","webc","whit","winw","wmlb","xda-"),Mid(user_agent,1,4),true))>-1 'Catch all
   mobile_browser = true
   mobile_browser_type = "2" 'Standard Phone
  Case Else
   mobile_browser = false
   mobile_browser_type = "0"
 End Select
  websitez_detect_mobile_device = array(mobile_browser,mobile_browser_type)
End Function

以下是Asp判断客户端操作系统源码,支持自定义关键词,支持“<img”方式调用:

<%
Function GetSysVer() '获取系统类型(可以判断:29种操作系统(包括手机))
GetSysVer="Other Unknown"
TheInfo = UCase(Request.ServerVariables("HTTP_USER_AGENT"))
if Instr(TheInfo,UCase("x11"))>0 or Instr(TheInfo,UCase("Unix"))>0 then GetSysVer="Unix"
if Instr(TheInfo,UCase("Sunos"))>0 or Instr(TheInfo,UCase("SUN OS"))>0 then GetSysVer="SUN OS"
if Instr(TheInfo,UCase("PowerPC"))>0 or Instr(TheInfo,UCase("PPC"))>0 then GetSysVer="PowerPC"
if Instr(TheInfo,UCase("Macintosh"))>0 then GetSysVer="Mac"
if Instr(TheInfo,UCase("Mac OSX"))>0 then GetSysVer="MacOSX"
if Instr(TheInfo,UCase("FreeBSD"))>0 then GetSysVer="FreeBSD"
if Instr(TheInfo,UCase("Linux"))>0 then GetSysVer="Linux"
if Instr(TheInfo,UCase("Palmsource"))>0 or Instr(TheInfo,UCase("PalmOS"))>0 then GetSysVer="PalmOS"
if Instr(TheInfo,UCase("WAP"))>0 then GetSysVer="WAP Mobile Phone"
if Instr(TheInfo,UCase("Win98"))>0 then GetSysVer="Win 98"
if Instr(TheInfo,UCase("NOKIAN"))>0 then GetSysVer="NOKIAN(诺基亚手机)"
if Instr(TheInfo,UCase("Media Center"))>0 then GetSysVer="Windows XP Media Center PC"
if Instr(TheInfo,UCase("Windows"))>0 then 
 GetSysVer="Windows Series"
 if Instr(TheInfo,UCase("Windows CE"))>0 then GetSysVer="Windows CE"
 if Instr(TheInfo,UCase("Windows 95"))>0 then GetSysVer="Windows 95"
 if Instr(TheInfo,UCase("Windows 98"))>0 then GetSysVer="Windows 98"
 if Instr(TheInfo,UCase("Windows 2000"))>0 then GetSysVer="Windows 2000"
 if Instr(TheInfo,UCase("Windows XP"))>0 then GetSysVer="Windows XP"
 if Instr(TheInfo,UCase("Windows NT"))>0 then
  GetSysVer="Windows NT Series"
  if Instr(TheInfo,UCase("Windows NT 4.0"))>0 then GetSysVer="Windows 9x/98/95"
  if Instr(TheInfo,UCase("Windows NT 5.0"))>0 then GetSysVer="Windows 2000"
  if Instr(TheInfo,UCase("Windows NT 5.1"))>0 then GetSysVer="Windows XP"
  if Instr(TheInfo,UCase("Windows NT 5.2"))>0 then GetSysVer="Windows Server 2003"
  if Instr(TheInfo,UCase("Windows NT 6.0"))>0 then GetSysVer="Windows Vista/Windows Server 2008"
  if Instr(TheInfo,UCase("Windows NT 6.1"))>0 then GetSysVer="Windows Server 2008 R2/Windows 7 Series"
 end if
end if
if Instr(TheInfo,UCase("Tablet PC"))>0 then GetSysVer=GetSysVer & "-Tablet PC(平板电脑)"
if Instr(TheInfo,UCase("Jakarta Commons"))>0 then GetSysVer=GetSysVer & "-Jakarta Commons-HttpClient"
if Instr(TheInfo,UCase("bsalsa.com"))>0 then GetSysVer=GetSysVer & "-[BOT]bsalsa.com(搜索引型)"
End Function

Response.Write GetSysVer
%>

判断访问浏览器的类型相关推荐

  1. javascript学习之利用DOM和正则表达式判断主流浏览器的类型

    火狐浏览器测试结果: 谷歌浏览器测试结果 IE8测试结果: IE11测试结果:

  2. .net中js判断浏览器的类型和版本

    你知道世界上有多少种浏览器吗?除了我们熟知的IE, Firefox, Opera, Safari四大浏览器之外,世界上还有近百种浏览器. 几天前,浏览器家族有刚诞生了一位小王子,就是Google推出的 ...

  3. JQuery 判断访问的浏览器是pc还是手机

    摘要 以下代码用于JQuery判断访问的浏览器的类型 /*** 判断访问类型是电脑还是手机* * @author * * 2017年9月27日*/$(function(){var mobile_fla ...

  4. php 判断来源 微信客户端_判断浏览器HTTP_USER_AGENT类型之微信浏览器判断

    在微信公众平台的开发过程中,我们有时需要开发网页并判断是否是是来自微信浏览器访问,本文介绍如何做出这一判断. 在学习这篇之前,应该先了解一下PHP 的 $_SERVER变量. 下面我们开始讲解具体方法 ...

  5. PHP和js判断访问设备是否是微信浏览器实例

    PHP和js判断访问设备是否是微信浏览器实例,代码非常精简,适合新手学习. js判断是否是微信浏览器: function is_weixin() { var ua = window.navigator ...

  6. JS判断访问设备(userAgent)加载不同页面 JS判断客户端操作系统类型(platform)

    //平台.设备和操作系统var system ={win : false,mac : false,xll : false};//检测平台var p = navigator.platform;syste ...

  7. 简易方法判断浏览器的类型和版本

    如何判断浏览器的类型和版本? -- 使用JavaScript的内置对象 navigator 的属性userAgent的值来判断(navigator.userAgent). navigator是java ...

  8. js判断客户浏览器类型,版本

    在JS中判断浏览器的 类型,估计是每个编辑过页面的开发人员都遇到过的问题.在众多的浏览器产品中,IE.Firefox.Opera.Safari........众多品牌 却标准不一,因此时常需要根据不同 ...

  9. javascript如何判断浏览器的类型?

    在前端开发中存在很多的浏览器,那么我们如何检测出浏览器的类型,下面我们主要总结一下. 一.userAgent 我们可以通过usrAgent来进行判断浏览器的类型. const explorer = w ...

  10. php判断苹果微信浏览器,php判断访问来源iphone,android,微信浏览器,pc电脑的方法

    php基于http协议访问,判断访问来源iphone,android,微信浏览器,pc电脑 当我们采用php作为服务数据端口,为移动端,pc端提供数据接口的时候,可能会要求记录接口访问的来源是来之哪里 ...

最新文章

  1. Java并发编程71道面试题及答案 1
  2. 定时器0工作方式2,定时1s
  3. 垃圾回收器的基本原理是什么?
  4. ssh: connect to host github.com port 22: Connection timed out
  5. 什么是mysql索引文件_数据库索引文件一般采用什么数据结构?
  6. java 人脸识别 demo_java引用Arcface,实现人脸识别(demo)
  7. android复选按钮,Android的复选框的详细开发案例分析
  8. mysql中设置字符_MySQL中设置默认字符集的方法
  9. https 密钥 php,https加密方式是什么
  10. linux版的微博客户端,在Linux下安装Weibird:查看和编写微博的GTK+客户端
  11. 一种语音识别的自动控制系统及方法与流程
  12. JavaScript中哪一种循环最快
  13. 【上采样问题】将浮点运算转换成整数运算
  14. matlab用ezplot绘制参数方程,MATLAB学习1 之画图函数
  15. Netapp 存储文件共享-windows 系统应用
  16. 第14章-cpp代码重用(其他继承模板)
  17. 浅谈打开网页速度慢的原因和解决方法
  18. 数据库系统的基本组成
  19. HLS调用vitis库
  20. 端午节送点话费给大家,千万别错过!

热门文章

  1. php网上花店管理系统的论文,网上花店管理系统
  2. 深入学习IOZone【转】
  3. 史上最简单的spark教程第十章-SparkSQL编程Java案例实践(二)
  4. 高漫数位板驱动下载安装
  5. ScreenToGif2.19.3中文版GIF录制工具
  6. Lottie 动画在项目中的使用总结
  7. 正运动控制器忘记地址怎么办?
  8. C++获取NTP服务器上的网络时间
  9. Java中的跨站请求伪造
  10. MTK车载平台添加或更换开机启动LOGO