Home > Web Front-end > JS Tutorial > JS identifies browser type (computer browser and mobile browser)

JS identifies browser type (computer browser and mobile browser)

高洛峰
Release: 2016-12-06 14:19:05
Original
1860 people have browsed it

No more nonsense, let me just post the code for you. The specific code is as follows:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" Content="text/html;charset=UTF-8"/>
<title>识别电脑浏览器和手机浏览器</title>
</head>
<script type="text/javascript">
var system ={};
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
if(system.win||system.mac||system.xll){
//如果是电脑跳转到百度
window.location.href="http://www.baidu.com/";
}else{
//如果是手机,跳转到hao123首页
window.location.href="http://www.hao123.com/";
}
</script>
<body>
</body>
</html>
Copy after login


Related labels:
js
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template