多了就不说了,直接上代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
 
function checkIsIphoneIpad()
{
	var pda_user_agent_list = new Array("iPhone", "iPod", "iPad"/*, "GTB"*/);
	var pda_app_name_list = new Array("Microsoft Pocket Internet Explorer");
//来自www.chhua.com
	var user_agent = navigator.userAgent.toString();
	for (var i=0; i<pda_user_agent_list.length; i++) {
		if (user_agent.indexOf(pda_user_agent_list[i]) >= 0) {
			return true;
		}
	}
	var appName = navigator.appName.toString();
	for (var i=0; i<pda_app_name_list.length; i++) {
		if (user_agent.indexOf(pda_app_name_list[i]) >= 0) {
			return true;
		}
	}
 
	return false;
}