<body>
<h1 id="text">websong</h1>
</body>
<script>
var text=document.querySelector('#text').innerText;
setInterval(function () {
if (navigator.onLine) {
//alert('online:有网络');
document.querySelector('#text').style.color='red';
document.querySelector('#text').innerText=text+'您的网络恢复了'
} else {
//alert('offline:断开网络');
document.querySelector('#text').style.color='blue';
document.querySelector('#text').innerText=text+'您断网了'
}
},1000)
</script>

  亲测在各个浏览器都可以跑,当然,低版本的我没试。

js判断网络连接情况:navigator.onLine的更多相关文章

  1. js判断网络连通性

    js判断网络连通性 if (window.navigator.onLine == true) {                         console.log("首次 -- 已连接 ...

  2. PhoneGap检测设备网络连接情况

    一.网络连接状态列表 Phonegap 网络连接通过 navigator.network.connection.type 来获取,一般有一下几种状态 1. Connection.UNKNOWN     ...

  3. Win8 app判断网络连接状态

    Win8 app判断网络连接状态 NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged; ...

  4. android中判断网络连接是否可用

    一.判断网络连接是否可用 public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = (C ...

  5. android判断网络连接状态、联网类型、运营商

    /** * 获取上网方式 * * @param mContext * @return */ public static String getNetType(Context mContext) { St ...

  6. c#判断网络连接状态示例代码

    使用c#判断网络连接状态的代码. 代码: public partial class Form1 : Form { [DllImport() == true) { label1.Text = " ...

  7. 【转】Linux下查看TCP网络连接情况

    查看TCP网络连接情况 命令:netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’ www.2cto.com 返回结 ...

  8. Window检测网络连接情况

    Window检测网络连接情况 #include "Wininet.h" #pragma comment(lib,"Wininet.lib") DWORD fla ...

  9. HttpUtil 【判断网络连接的封装类】

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 该封装类主要包括以下功能: 判断是否有网络连接.判断是否有可用的网络连接: 判断是否是3G网络.判断mobile网络是否可用: 判断 ...

随机推荐

  1. 题解【bzoj1010 [HNOI2008]玩具装箱TOY】

    斜率优化动态规划可以用来解决这道题.同时这也是一道经典的斜率优化基础题. 分析:明显是动态规划.令\(dp[i]\)为前\(i\)个装箱的最小花费. 转移方程如下: \[dp[i]=\min\limi ...

  2. Qt ------ 初始化构造函数参数,parent

    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setup ...

  3. Zabbix Server端配置文件

    Zabbix Server端配置文件说明 # This is a configuration file for Zabbix Server process # To get more informat ...

  4. maven工程pom.xml报Missing artifact net.sf.jasperreports:jasperreports:jar:6.2.0

    有时maven工程的pom.xml报以下类型错误: Description Resource Path Location TypeMissing artifact net.sf.jasperrepor ...

  5. session验证-使用filter过滤器

    public override void OnActionExecuting(ActionExecutingContext context) { string test = context.Contr ...

  6. Beagleboneblack的MLO文件干了些啥

    Beagleboneblack在启动linux之前还有三个启动阶段: ROM code  -->  MLO  -->  u-boot --> kernel 先看看ROM code干了 ...

  7. IntentServicce;Looper;long-running task

    7. If you want to carry on a long-running task, what do you need to do? IntentService:Service Servic ...

  8. 【Codeforces549F】Yura and Developers [单调栈][二分]

    Yura and Developers Time Limit: 20 Sec  Memory Limit: 512 MB Description Input Output Sample Input 4 ...

  9. Spring注解概览(数漫江湖)

    从Java5.0开始,Java开始支持注解.Spring做为Java生态中的领军框架,从2.5版本后也开始支持注解.相比起之前使用xml来配置Spring框架,使用注解提供了更多的控制Spring框架 ...

  10. H题 hdu 2520 我是菜鸟,我怕谁

    题目大意:http://acm.hdu.edu.cn/showproblem.php?pid=2520 我是菜鸟,我怕谁 Time Limit: 2000/1000 MS (Java/Others)  ...