判断各种手机User-Agent

List of user agents for mobile phones

它的网址是:http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones

代码如下所示:

<%
	String userAgent = request.getHeader("User-Agent");
	if(userAgent.indexOf("Mozilla")!=-1 && userAgent.indexOf("iPhone")!=-1 || userAgent.indexOf("Android")!=-1 ){
		response.sendRedirect("页面1");
	}else if(userAgent.indexOf("Opera")!=-1 && userAgent.indexOf("Opera Mini")!=-1 || userAgent.indexOf("BlackBerry")!=-1){
		response.sendRedirect("页面2");
	}else if(userAgent.indexOf("Mozilla")!=-1 && userAgent.indexOf("Windows")!=-1){
		response.sendRedirect("页面3");
	}else{
		response.sendRedirect("页面1");
	}
%>

 

 

你可能感兴趣的:(判断各种手机User-Agent)