js判断网络连通性

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("网络未连接--请检查网络");
                    }
上一篇:C++版 - 剑指offer 面试题24:二叉搜索树BST的后序遍历序列(的判断) 题解


下一篇:在PHP中管理环境变量