码迷,mamicode.com
首页 > Web开发 > 详细

js判断网络连通性

时间:2018-04-12 13:30:21      阅读:305      评论:0      收藏:0      [点我收藏+]

标签:bsp   上网   data   判断   lse   json   ==   --   status   

js判断网络连通性
if (window.navigator.onLine == true) {
                        console.log("首次 -- 已连接")
                        $.ajax({
                            url: "https://www.baidu.com/",
                            type: "POST",
                            timeout: 1000,
                            dataType: "json",
                        }).complete(function (XMLHttpRequest) {
                            console.log(XMLHttpRequest);
                            if (XMLHttpRequest.status == 200) {
                                $notification.show("已经可以正常上网", !0);
                            } else {
                                console.log("准备打开上网认证界面");
                                window.open(e, i);
                            }
                        });
                    } else {
                        $notification.show("网络未连接--请检查网络");
                    }

js判断网络连通性

标签:bsp   上网   data   判断   lse   json   ==   --   status   

原文地址:https://www.cnblogs.com/oycyqr/p/8806874.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!