把下面的代码放在app\common.php公共方法那里. function isMobile() { if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) { return true; } if (isset($_SERVER['HTTP_VIA'])) { return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false; } if (isset($_SERVER['HTTP_USER_AGENT'…
废话不多说,直接上代码 先修改\thinkphp\library\think\view\driver\Think.php文件 把 public function __construct($config = []){  $this->config = array_merge($this->config, $config);  if (empty($this->config['view_path']) && defined('VIEW_PATH')) {  $this->…
function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; ; v < Agents.length; v++) { ) { fl…
JavaScript判断移动端及pc端访问不同的网站 现在很多网站都是分为两个版本,一个pc端的一个移动端的(响应式除外),针对这两个版本,就需要对访问的设备进行判断,如果是pc,就直接访问pc网站,否则就访问移动端网站. 对于这个问题可以通过判断UA来解决,前端js可以判断,后端判断也行,这里我们主要讨论的是如何通过js来处理. 假如我们有一个网站,pc端通过www.test.com访问,而移动端通过m.test.com来访问.我们需要做的就是当移动端访问www.test.com时可以直接跳转…
function isMobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) { return true; } // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 if (isset ($_SERVER['HTTP_VIA'])) { // 找不到为flase,否则为true return stristr($_SERVER['HTTP_VIA'], "wap…
1. 判断浏览器是pc端还是手机端 <script type="text/javascript"> var browser = { versions: function() { var u = navigator.userAgent, app = navigator.appVersion; return { //移动终端浏览器版本信息 trident: u.indexOf(, //IE内核 presto: u.indexOf(, //opera内核 webKit: u.in…
判断设备是PC端,还是移动端 var ua = navigator.userAgent.toLocaleLowerCase(); var pf = navigator.platform.toLocaleLowerCase(); var isAndroid = (/android/i).test(ua)||((/iPhone|iPod|iPad/i).test(ua) && (/linux/i).test(pf)) || (/ucweb.*linux/i.test(ua)); var isI…
微信浏览器的页面在PC端访问: 普通的在微信浏览器看的页面如果不在php代码中解析一下,然后复制链接在PC打开就出现无法访问,因为它复制的地址是: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3ddcdc079ccd2ad7&redirect_uri=http%3A%2F%2Fjiyuqiao.welinli.com%2Findex.php%3Fs%3D%2Fwechat%2Fzwfw%2Findex.html&r…
js判断页面在pc端打开还是移动端打开,分别跳转不同的index.html window.addEventListener('load', function() { // true为手机,false为pc if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) { //跳转到移动端 window.location.href = window.location.href.concat('m/'); } else if (!navigato…
java 判断用户是PC端和还是APP端登陆 public void getRequestHeader(HttpServletRequest request){ // 从浏览器获取请求头信息 String info= request.getHeader("user-agent"); if(info.contains("Windows")){ System.out.println("Windows pc端登陆"); return; } if(inf…