吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1449|回复: 4
收起左侧

[Android 求助] 判断移动端的在qq浏览器里不生效

[复制链接]
坏小子8 发表于 2020-7-9 16:44
下面这这个判断移动端的在qq浏览器里不生效
要实现的功能是屏蔽指定地区和pc端 无线端跳转到指定页面
求大佬给改下  

<script>
$.getScript('https://ip.ws.126.net/ipquery', function(){  
     console.log(localAddress.city)
    if(localAddress.city.indexOf('北京') != -1||localAddress.city.indexOf('成都') != -1||localAddress.city.indexOf('上海') != -1||localAddress.city.indexOf('广州') != -1||localAddress.city.indexOf('深圳') != -1||localAddress.city.indexOf('东莞') != -1){        
       window.location.href = 'http://www.baidu.com';      
    }else{        
     return;      
    }
});
</script>
<script>
var mobile_bs = {
    versions: function() {
        var u = navigator.userAgent;
        return {
            trident: u.indexOf('Trident') > -1, //IE内核
            presto: u.indexOf('Presto') > -1,  //opera内核
            webKit: u.indexOf('AppleWebKit') > -1,  //苹果、谷歌内核
            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,  //火狐内核
            mobile: !! u.match(/AppleWebKit.*Mobile.*/) || !! u.match(/AppleWebKit/) && u.indexOf('QIHU') && u.indexOf('QIHU') > -1 && u.indexOf('Chrome') < 0,  //是否为移动终端
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),  //ios终端
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,  //android终端或者uc浏览器
            iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1,   //是否为iPhone或者QQHD浏览器
            iPad: u.indexOf('iPad') > -1,     //是否iPad
            webApp: u.indexOf('Safari') == -1   //是否web应该程序,没有头部与底部
        }
    } ()
};

if (mobile_bs.versions.mobile) {
    if (mobile_bs.versions.android || mobile_bs.versions.iPhone || mobile_bs.versions.iPad || mobile_bs.versions.ios) {
        window.location.href ="http://www.baidu.com";
    }
};
</script>

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| 坏小子8 发表于 2020-7-9 17:27
本帖最后由 坏小子8 于 2020-7-9 17:38 编辑
Lebal 发表于 2020-7-9 17:21
你现在的代码就实现了屏蔽指定地区和pc端 无线端跳转到指定页面,

用$.getScript的话是否引入了jq?

有引入jquery/2.0  现在的问题是 在无线端QQ浏览器内不生效 不跳转
Lebal 发表于 2020-7-9 17:21
你现在的代码就实现了屏蔽指定地区和pc端 无线端跳转到指定页面,

用$.getScript的话是否引入了jq?
儒雅绅士 发表于 2020-7-9 17:45
本帖最后由 儒雅绅士 于 2020-7-9 17:48 编辑

你下载个浏览器控制台执行下 navigator.userAgent  看看浏览器打印出什么就知道了呗。由于没有QQ浏览器百度了一下
完整代码如下
<script>
var mobile_bs = {
    versions: function() {
        var u = navigator.userAgent;
        return {
            trident: u.indexOf('Trident') > -1, //IE内核
            presto: u.indexOf('Presto') > -1,  //opera内核
            webKit: u.indexOf('AppleWebKit') > -1,  //苹果、谷歌内核
            gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,  //火狐内核
            mobile: !! u.match(/AppleWebKit.*Mobile.*/) || !! u.match(/AppleWebKit/) && u.indexOf('QIHU') && u.indexOf('QIHU') > -1 && u.indexOf('Chrome') < 0,  //是否为移动终端
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),  //ios终端
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,  //android终端或者uc浏览器
            iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1,   //是否为iPhone或者QQHD浏览器
            iPad: u.indexOf('iPad') > -1,     //是否iPad
            qq: u.indexOf('MQQBrowser') > -1 && u.indexOf(' QQ') === -1,
            webApp: u.indexOf('Safari') == -1   //是否web应该程序,没有头部与底部
        }
    } ()
};

if (mobile_bs.versions.mobile) {
    if (mobile_bs.versions.android || mobile_bs.versions.iPhone || mobile_bs.versions.iPad || mobile_bs.versions.ios || mobile_bs.versions.qq) {
        window.location.href ="http://www.baidu.com";
    }
};
</script>
加上试试
 楼主| 坏小子8 发表于 2020-7-10 10:14
儒雅绅士 发表于 2020-7-9 17:45
你下载个浏览器控制台执行下 navigator.userAgent  看看浏览器打印出什么就知道了呗。由于没有QQ浏览器百度 ...

可以了感谢大佬
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-25 22:31

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表