<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. jq 数组定义,拼接~~~push应用

    var radio_checked_array = []; $("input[type='radio']").each(function(){ if($(this).attr('c ...

  2. [技巧篇]01.Servlet的优化模版代码

    Servlet.java的模版 #---------------------------------------------# # <aw:description>Template for ...

  3. ZooKeeper内部构件

    引言 这个文档包含关于ZK内部工作的信息.目前为止,它讨论了这些主题: 原子广播 日志 原子传播 ZK的核心是一个原子的通信系统,它使所有的服务端保持同步. 保证.属性和定义 通过使用ZooKeepe ...

  4. You can't specify target table 'table' for update in FROM clause

    delete from table1 where ID not in(select max(ID) ID from table1 group by row1) and row1 ) # 出现错误 # ...

  5. LightOJ 1319 - Monkey Tradition CRT除数互质版

    本题亦是非常裸的CRT. CRT的余数方程 那么定义 则 其中 为模mi的逆元. /** @Date : 2016-10-23-15.11 * @Author : Lweleth (SoungEarl ...

  6. jquery字符串序列化方法总结

    在jquery中字符串序列化方法包括有param() .serialize() .serializeArray(),在这里对其常用做法进行总结. $.param()方法这是serialize()方法的 ...

  7. 通过java客户端连接hbase 注意事项

    1.通过Java客户端连接Hbase,其中hbase通过zookeeper去管理,需要注意的是客户端端口. 通过在浏览器端输入地址查看:http://192.168.3.206:60010/maste ...

  8. 【BZOJ1560】【JSOI2009】火星藏宝图 [DP]

    火星藏宝图 Time Limit: 10 Sec  Memory Limit: 64 MB[Submit][Status][Discuss] Description Input Output Samp ...

  9. 【Foreign】咏叹 [模拟退火]

    咏叹 Time Limit: 100 Sec  Memory Limit: 256 MB Description 有n根木棍,第i根长度为ai.你要贴着墙围出一个矩形区域,木棍围成的矩形边缘必须平行或 ...

  10. PHP is_null,empty以及isset,unset的区别

    1.empty 判断一个变量是否为“空”.null.false.00.0.’0′.』.为以上值的变量在检测時都将返回true. 2.isset 判断一个变量是否已经设置.0.00.’0′.』.’ ‘. ...