<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style>
#b1 {
width:100px;
height:100px;
border:1px red solid;
margin:100px;
}
</style>
</head>
<div id="b1"></div>
<body>
<script>
function goPAGE(){
var res = document.getElementById('b1');
if((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
// window.location.href="移动端url";
res.style.background = "red";
}else {
// window.location.href="pc端url";
res.style.background = "blue";
}
}
goPAGE(); // 调用function
</script>
</body>
</html>
PC端和移动端判断
最新推荐文章于 2022-10-17 22:05:23 发布