4***@qq.com
4***@qq.com
  • 发布:2016-10-14 12:00
  • 更新:2016-11-18 09:12
  • 阅读:1259

【报Bug】

分类:HTML5+

详细问题描述
在webView页面中使用js 获取客户端的内网IP地址,重复请求数据不刷新,重启应用也不刷新,必须关闭软件,清除手机APP运行缓存才可以。在手机谷歌浏览器下运行就没有问题

运行环境
安卓6.0
华为P9青春版,VIVO rpo
HBuilder 7.4.2.201609122322

附件

test

<script>
getIPs(function(ip) {

    if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) {  
        alert(ip);  
    }  
});  

function getIPs(callback) {  
    var ip_dups = {};  

    //compatibility for firefox and chrome     
    var RTCPeerConnection = window.RTCPeerConnection  
            || window.mozRTCPeerConnection  
            || window.webkitRTCPeerConnection;  
    var mediaConstraints = {  
        optional: [{RtpDataChannels: true}]  
    };  

    //firefox already has a default stun server in about:config     
    //    media.peerconnection.default_iceservers =     
    var servers = undefined;  

    //add same stun server for chrome     
    if (window.webkitRTCPeerConnection)  
        servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};  

    //construct a new RTCPeerConnection     
    var pc = new RTCPeerConnection(servers, mediaConstraints);  

    //listen for candidate events     
    pc.onicecandidate = function(ice) {  

        //skip non-candidate events     
        if (ice.candidate) {  

            //match just the IP address     
            var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/;  
            var ip_addr = ip_regex.exec(ice.candidate.candidate)[1];  

            //remove duplicates     
            if (ip_dups[ip_addr] === undefined)  
                callback(ip_addr);  

            ip_dups[ip_addr] = true;  
        }  
    };  

    //create a bogus data channel     
    pc.createDataChannel("");  

    //create an offer sdp     
    pc.createOffer(function(result) {  

        //trigger the stun server request     
        pc.setLocalDescription(result, function() {  
        });  

    }, function() {  
    });  
}  

</script>

联系方式
460010009
15261437592

2016-10-14 12:00 负责人:无 分享
已邀请:
5***@qq.com

5***@qq.com

你有整个页面吗,能不能发给我下啊,谢谢

该问题目前已经被锁定, 无法添加新回复