superior_2008 发表于 2011-12-21 08:44

Check Broswer UserAgent

<div>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"</div><div>&nbsp; &nbsp; pageEncoding="UTF-8"%&gt;</div><div>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;</div><div>&lt;html&gt;</div><div>&lt;head&gt;</div><div>&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;</div><div>&lt;title&gt;Insert title here&lt;/title&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;%</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>String userAgent = request.getHeader("User-Agent");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>String target = "";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>out.println("userAgent=" + userAgent);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>target = getMobileOSFromUserAgent(userAgent) + &nbsp;"-" + getPCOSFromUserAgent(userAgent) +"-" + getBroswerTypeFromUserAgent(userAgent);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>out.println("target=" + target);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>%&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;%!</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Check Mobile OS</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String getMobileOSFromUserAgent(String userAgent){</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>String type="";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if(userAgent.indexOf("Windows CE",1)&gt;0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type = "Windows CE|手机系统";<span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("iPhone",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="iPhone|手机系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("BlackBerry",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="BlackBerry|手机系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Series60",1) &gt; 0 &amp;&amp; userAgent.indexOf("NOKIA",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Nokia S60|手机系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("NOKIA",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="NOKIA|手机系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("SymbianOS",1) &gt; 0 || userAgent.indexOf("Series",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="SymbianOS|手机系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("SonyEricsson",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="SonyEricsson|手机系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return type;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//Check PC OS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String getPCOSFromUserAgent(String userAgent){</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>String type = "";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if(userAgent.indexOf("Windows NT 6.1",1)&gt;0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type = "Windows 7|电脑系统";<span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Windows NT 6.0",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Windows Vista|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Windows NT 5.2",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Windows 2003|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Windows NT 5.1",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Windows XP|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Windows NT 5.0",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Windows 2000|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Windows NT",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Windows NT|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Windows 9",1) &gt; 0 || userAgent.indexOf("Windows 4",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Windows 9x|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Unix",1) &gt; 0 || userAgent.indexOf("SunOS",1) &gt; 0 || userAgent.indexOf("BSD",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Unix|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("RedHat",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Linux RedHat|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Ubuntu",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Linux Ubuntu|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Linux",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Linux|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Mac",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="Mac|电脑系统";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return type;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// check broswer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String getBroswerTypeFromUserAgent(String userAgent){</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>String type = "";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//Use the Kernel of IE:MAXTHON,GreenBrowser TencentTraveler MyIE NetCaptor</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if(userAgent.indexOf("GreenBrowser",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="GreenBrowser|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("NetCaptor",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="NetCaptor|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("TencentTraveler",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="TencentTraveler|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("TheWorld",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="TheWorld|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MAXTHON",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="Maxthon|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MyIE",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="MyIE|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//IE</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>else if(userAgent.indexOf("MSIE 8",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="IE 8|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MSIE 7",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="MSIE 7|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MSIE 6",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="MSIE 6|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MSIE 5",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="IE 5|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MSIE 4",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="MSIE 4|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("MSIE 3",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="MSIE 3|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//None IE</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>else if(userAgent.indexOf("Netscape",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="Netscape|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Chrome",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="Chrome|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Firefox",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="Firefox|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Safari",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="vs|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Opera Mini",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="Opera Mini|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("Opera",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="Opera|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("R4EA",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="R4EA|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("UP",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type="UP|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}else if(userAgent.indexOf("UCWEB",1) &gt; 0){</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>type+="UCWEB|浏览器";</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return type;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>%&gt;</div><div>&lt;/head&gt;</div><div>&lt;body&gt;</div><div>&lt;/body&gt;</div><div>&lt;/html&gt;</div><div><br></div><div><br></div><div><br></div><div><div>&lt;%dim UserAgent1</div><div><br></div><div>UserAgent1=""&amp;trim(Request.ServerVariables("HTTP_USER_AGENT"))&amp;""</div><div>if UserAgent1="" then</div><div>&nbsp; &nbsp;UserAgent1="UserAgent Unknown"</div><div>else</div><div>&nbsp; &nbsp;UserAgent1=""&amp;UserAgent1&amp;""</div><div>end if</div><div>Function getOS(UserAgent)</div><div>'下面三种判定,写在一起</div><div>&nbsp; &nbsp; if UserAgent="UserAgent Unknown" then :vOs="UserAgent isNull OS Unknown|Other":getOS=vOS:exit Function:end if</div><div>&nbsp; &nbsp; dim vOS</div><div>'-------先判定手机系统</div><div>if instr(1,UserAgent,"Windows CE",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Windows CE|手机系统"</div><div>elseif instr(1,UserAgent,"iPhone",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="iPhone|手机系统"</div><div>elseif instr(1,UserAgent,"BlackBerry",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="BlackBerry|手机系统"</div><div>elseif instr(1,UserAgent,"Series60",1)&gt;0 and instr(1,UserAgent,"NOKIA",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Nokia S60|手机系统"</div><div>elseif instr(1,UserAgent,"NOKIA",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Nokia|手机系统"</div><div>elseif instr(1,UserAgent,"SymbianOS",1)&gt;0 or instr(1,UserAgent,"Series",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="SymbianOS|手机系统"</div><div>elseif instr(1,UserAgent,"SonyEricsson",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="SonyEricsson|手机系统"</div><div>elseif instr(1,UserAgent,"LG",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="LG手机|手机系统"</div><div>elseif instr(1,UserAgent,"MOT",1)&gt;0 or instr(1,UserAgent,"Motorola",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="MOTO手机|手机系统"</div><div>elseif instr(1,UserAgent,"SEC",1)&gt;0 or instr(1,UserAgent,"SAMSUNG",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="三星手机|手机系统"</div><div>elseif instr(1,UserAgent,"ZTE")&gt;0 then</div><div>&nbsp; &nbsp;vOs="中兴手机|手机系统"</div><div>elseif instr(1,UserAgent,"DX",1)&gt;0 or instr(1,UserAgent,"DAXIAN",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="大显手机|手机系统"</div><div>elseif instr(1,UserAgent,"TELSON",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="泰信[代工]手机|手机系统"</div><div>elseif instr(1,UserAgent,"Dopod",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="多普达手机|手机系统"</div><div>elseif instr(1,UserAgent,"PHILIPS",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="PHILIPS手机|手机系统"</div><div>elseif instr(1,UserAgent,"Haier",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="海尔手机|手机系统"</div><div>elseif instr(1,UserAgent,"LENOVO",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="联想手机|手机系统"</div><div>elseif instr(1,UserAgent,"CECT",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="CECT手机|手机系统"</div><div>elseif instr(1,UserAgent,"NEC",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="NEC手机|手机系统"</div><div>elseif instr(1,UserAgent,"Bird",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="波导手机|手机系统"</div><div>elseif instr(1,UserAgent,"DBTEL",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="迪比特手机|手机系统"</div><div>elseif instr(1,UserAgent,"TCL",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="TCL手机|手机系统"</div><div>elseif instr(1,UserAgent,"oppo",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Oppo手机|手机系统"</div><div>elseif instr(1,UserAgent,"AMOI",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="夏新手机|手机系统"</div><div>elseif instr(1,UserAgent,"Alcatel",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="阿尔卡特手机|手机系统"</div><div>elseif instr(1,UserAgent,"Ericsson",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="爱立信手机|手机系统"</div><div>elseif instr(1,UserAgent,"BenQ",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="明基手机|手机系统"</div><div>elseif instr(1,UserAgent,"KONKA",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="康佳手机|手机系统"</div><div>elseif instr(1,UserAgent,"ChangHong",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="长虹手机|手机系统"</div><div>elseif instr(1,UserAgent,"MALATA",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="万利达手机|手机系统"</div><div>elseif instr(1,UserAgent,"KTOUCH",1)&gt;0 or instr(1,UserAgent,"TIANYU",1)&gt;0 or instr(1,UserAgent,"K-TOUCH",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="天语手机|手机系统"</div><div>'---------------下面2个要在手机中最后判定,最普通的手机了MAUI-----------</div><div>elseif instr(1,UserAgent,"MAUI",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="MTK杂牌手机|手机系统"</div><div>elseif instr(1,UserAgent,"MIDP",1)&gt;0 or instr(1,UserAgent,"JAVA",1)&gt;0 or instr(1,UserAgent,"J2ME",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Java移动设备|手机系统"</div><div>else</div><div>&nbsp; &nbsp;vOs="Other|手机系统"</div><div>end if</div><div>if vOs&lt;&gt;"Other|手机系统" then:getOS=vOS:exit Function:end if</div><div><br></div><div>'---------再判定电脑系统</div><div>if instr(1,UserAgent,"Windows NT 6.1",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Windows 7|电脑系统"</div><div>elseif instr(1,UserAgent,"Windows NT 6.0",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Windows Vista|电脑系统"</div><div>elseif instr(1,UserAgent,"Windows NT 5.2",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Windows 2003|电脑系统"</div><div>elseif instr(1,UserAgent,"Windows NT 5.1",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Windows XP|电脑系统"</div><div>elseif instr(1,UserAgent,"Windows NT 5.0",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Windows 2000|电脑系统"</div><div>elseif instr(1,UserAgent,"Windows NT",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Windows NT|电脑系统"</div><div>&nbsp; &nbsp;</div><div>'4.0 is win95 ,4.1 is win98 ,4.9 is win me</div><div>elseif instr(1,UserAgent,"Windows 9",1)&gt;0 or instr(1,UserAgent,"Windows 4",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Windows 9x|电脑系统"</div><div>elseif instr(1,UserAgent,"Unix",1)&gt;0 or instr(1,UserAgent,"SunOS",1)&gt;0 or instr(1,UserAgent,"BSD",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Unix|电脑系统"</div><div>elseif instr(1,UserAgent,"RedHat",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Linux RedHat|电脑系统"</div><div>elseif instr(1,UserAgent,"Ubuntu",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Linux Ubuntu|电脑系统"</div><div>elseif instr(1,UserAgent,"Linux",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Linux|电脑系统"</div><div>elseif instr(1,UserAgent,"Mac",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Mac|电脑系统"</div><div>else</div><div>&nbsp; &nbsp;vOs="Other|电脑系统"</div><div>end if</div><div>if vOs&lt;&gt;"Other|电脑系统" then:getOS=vOS:exit Function:end if</div><div>'以上判定电脑系统完完毕BlackBerry</div><div><br></div><div><br></div><div>'-------最后判定搜索蜘蛛</div><div>'蜘蛛spiderAlcatel</div><div>if instr(1,UserAgent,"Baiduspider",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Baidu spider|搜索蜘蛛"</div><div>elseif instr(1,UserAgent,"Googlebot",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Google bot|搜索蜘蛛"</div><div>elseif instr(1,UserAgent,"msnbot",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Msn bot|搜索蜘蛛"</div><div>elseif instr(1,UserAgent,"Yahoo",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Yahoo bot|搜索蜘蛛"</div><div>elseif instr(1,UserAgent,"Sogou",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Sogou spider|搜索蜘蛛"</div><div>elseif instr(1,UserAgent,"YodaoBot",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Yodao Bot|搜索蜘蛛"</div><div>elseif instr(1,UserAgent,"Sosospider",1)&gt;0 then</div><div>&nbsp; &nbsp;vOs="Soso spider|搜索蜘蛛"</div><div>else</div><div>&nbsp; &nbsp;vOs="Other|搜索蜘蛛"</div><div>end if</div><div><br></div><div>getOS=vOS</div><div>if vOs="Other|搜索蜘蛛" then:vOs="Other|Other":getOS=vOS:exit Function:end if</div><div>&nbsp; &nbsp;&nbsp;</div><div>end Function</div><div><br></div><div>Function getIE(UserAgent)</div><div>if UserAgent="UserAgent Unknown" then :vOs="UserAgent isNull Browser Unknown|Other":getIE=vOS:exit Function:end if</div><div>dim vOS</div><div><br></div><div>'先判定使用IE内核的浏览器MAXTHON,GreenBrowser TencentTraveler MyIE NetCaptor</div><div>if instr(1,UserAgent,"GreenBrowser",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="GreenBrowser|浏览器"</div><div>elseif instr(1,UserAgent,"NetCaptor",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="NetCaptor|浏览器"</div><div>elseif instr(1,UserAgent,"TencentTraveler",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="TencentTraveler|浏览器"</div><div>elseif instr(1,UserAgent,"TheWorld",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="TheWorld|浏览器"</div><div>elseif instr(1,UserAgent,"MAXTHON",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Maxthon|浏览器"</div><div>elseif instr(1,UserAgent,"MyIE",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="MyIE|浏览器"</div><div>'用IE内核的浏览器的判定要在IE前进行</div><div>elseif instr(1,UserAgent,"MSIE 8",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 8|浏览器"</div><div>elseif instr(1,UserAgent,"MSIE 7",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 7|浏览器"</div><div>elseif instr(1,UserAgent,"MSIE 6",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 6|浏览器"</div><div>elseif instr(1,UserAgent,"MSIE 5.5",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 5.5|浏览器"</div><div>elseif instr(1,UserAgent,"MSIE 5",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 5|浏览器"</div><div>elseif instr(1,UserAgent,"MSIE 4",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 4|浏览器"</div><div>elseif instr(1,UserAgent,"MSIE 3",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="IE 3|浏览器"</div><div>&nbsp; &nbsp;</div><div>'下面是非IE内核浏览器</div><div>elseif instr(1,UserAgent,"Netscape",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Netscape|浏览器"</div><div>elseif instr(1,UserAgent,"Chrome",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Chrome|浏览器"</div><div>elseif instr(1,UserAgent,"Firefox",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Firefox|浏览器"</div><div>elseif instr(1,UserAgent,"Safari",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Safari|浏览器"</div><div>elseif instr(1,UserAgent,"Opera Mini",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Opera Mini|浏览器"</div><div>elseif instr(1,UserAgent,"Opera",1)&gt;0 or instr(1,UserAgent,"Presto",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="Opera|浏览器"</div><div>elseif instr(1,UserAgent,"R4EA",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="R4EA|浏览器"</div><div>elseif instr(1,UserAgent,"UP",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="UP|浏览器"</div><div>elseif instr(1,UserAgent,"UCWEB",1)&gt;0 then</div><div>&nbsp; &nbsp;vOS="UCWEB|浏览器"</div><div>else</div><div>&nbsp; &nbsp;vOS="Other|浏览器"</div><div>end if</div><div>&nbsp; &nbsp; getIE=vOS</div><div>end Function</div><div><br></div><div>%&gt;</div></div>
页: [1]
查看完整版本: Check Broswer UserAgent