onlinenetwork

js判断是否断网了

Stars
98
Committers
1

Bot releases are visible (Hide)

onlinenetwork - onlinenetwork v0.2 Latest Release

Published by jaywcjlove over 9 years ago

更改接口调用方式

设置轮询时间和地址

time: 时间不设置默认2000
url:不设置默认所有浏览器用 onlineoffline事件

var net = onlinenetwork({
    "time":1000,
    "url":"http://*******.com/ping.php"
})

连上网络执行

net.onLineHandler(function(){
    console.log("连上了!")
})

断开网络执行

net.offLineHandler(function(){
    console.log("断开网络!")
})
onlinenetwork - onlinenetwork v0.1

Published by jaywcjlove over 9 years ago

设置轮询时间和地址

**必须:**在online.js中设置以下

time 设置轮询时间
urlurl为空的时候 默认所有浏览器使用 onLine 和 offline事件

  • url 不为空的时候 IE 和 Firefox 使用 AJAX 轮询判断网络是否连接
  • url 请求的可以是服务器一个空php 等文件
  • 文件可以设置头文件,避免轮询跑更多的流量

侦听是否连上网络

window.onLineHandler = function(){
    console.log("连上了!")
};

侦听是否断开网络

window.offLineHandler = function(){
    console.log("断开网络!")
};
Package Rankings
Top 15.08% on Bower.io
Badges
Extracted from project README
GitHub issues GitHub forks GitHub stars