判断页面是在移动端还是PC端打开的
$(function () {
var curWwwPath = window.document.location.href;
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
var localhostPaht = curWwwPath.substring(0, pos);
var host = window.location.host;
var sUserAgent= navigator.userAgent.toLowerCase();
var bIsIpad= sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs= sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp= sUserAgent.match(/midp/i) == "midp";
var bIsUc7= sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc= sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid= sUserAgent.match(/android/i) == "android";
var bIsCE= sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM= sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
//mobile
if ((localhostPaht +"//"+host) != 'https://m.meiwo.cn'){
window.location.href = 'https://m.meiwo.cn';
}
} else {
//pc
if ((localhostPaht +"//" +host) != 'https://www.meiwo.cn'){
window.location.href = 'https://www.meiwo.cn';
}
}
})
window.location.href = /Android|webOS|iPhone|iPad|BlackBerry/i.test(navigator.userAgent) ? "https://www.baidu.com/" : "http://news.baidu.com/";
或
if(/Android|webOS|iPhone|iPad|BlackBerry/i.test(navigator.userAgent)) {
window.location.href = "https://www.baidu.com/";
} else {
window.location.href = "http://news.baidu.com/";
}
最新文章
- 【leetcode】Valid Sudoku
- HTML5触摸事件(touchstart、touchmove和touchend) (转)
- paip.lucene 4.3 中文语义搜索最佳实践
- angular 三目运算符 需要换色或style
- HDU 1402 fft 模板题
- yum 安装包的用法
- twitter storm源码走读之1 -- nimbus启动场景分析
- C类地址
- 【Android 界面效果20】Android GradientDrawable类的详解,设置activity的背景颜色渐变效果
- Linxu安装Lamp环境
- JQ 无刷新评论
- 使用 Chrome 来调试你的 Android App
- UISearchBar总结
- s=a+aa+aaa+aaaa+aa...aaaa
- fdisk磁盘分区与挂载
- SpringBoot Web开发(4) Thymeleaf模板与freemaker
- React Router 用法
- es6函数的新语法
- Linux - DNF包管理
- .NetCore 中如何实现分页以及编写一个URL分页
热门文章
- javascript之日期对象(Date)
- 八十二:memcached之python操作memcached
- SAP Query创建
- 最短路径:Dijkstra算法 C#
- 002. Add Two Numbers
- django在style的样式image url添加静态图片路径和django如何动态传入图片链接?
- Python爬虫学习==>;第六章:爬虫的基本原理
- DirectX* 11 多线程渲染的性能、方法和实践
- 【JulyEdu-Python基础】第 2 课:关键字和循环控制
- python selenium API 常用方法