<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Online and offline events</title>
</head>
<body>
<div id="status"><p id="state"></p></div>
<div id="log"></div>
<div>ps:Firefox 3 introduces two new events: <a href="https://developer.mozilla.org/en/Online_and_offline_events">"online" and "offline"</a>. </div>
<script>
function updateOnlineStatus(msg) {
var status = document.getElementById("status");
var condition = navigator.onLine ? "ONLINE" : "OFFLINE";
status.setAttribute("class", condition);
var state = document.getElementById("state");
state.innerHTML = condition;
var log = document.getElementById("log");
log.innerHTML+="Event: " + msg + "; status=" + condition + "<br/>";
}
function loaded() {
updateOnlineStatus("load");
if(!window.addEventListener){//傲游的事件检测不到,支持ie8,(ie6,7未测试)
document.addEventListener=function(etype,callback){
document.bdoy.attachEvent("on"+etype,callback);//IE8只支持document.body,不支持document和window
}
}
document.addEventListener("offline", function () {//opera 10.53不支持,chrome5,safari4没找到设置
updateOnlineStatus("offline")
}, false);
document.addEventListener("online", function () {
updateOnlineStatus("online")
}, false);
}
window.onload=loaded;
</script>
</body>
</html>
分享到:
相关推荐
How Online Social Network Affects Offline Events A Case Study on Douban
在技术实现上,"online-offline-budget-trackers"很可能是利用了现代Web技术,尤其是JavaScript,来构建前端界面和处理用户的交互。JavaScript是Web开发中的关键语言,用于动态更新网页内容,创建交互式用户体验。在...
This pattern extends to various other activities, with most offline events also having an online counterpart. As society continues to evolve, the convenience of daily leisure activities and the ...
当连接状态从脱机状态更改为联机状态时,将cordova.network.online 。 或者,当设备或浏览器脱机时,将触发cordova.network.offline 。 如果您喜欢这样工作,这两个事件使您可以收听事件。 最后,作为第三个替代...
JQuery Mobile 应用程序对象和事件你会看到很多类似... Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDevice
Channel strategy should consider both offline and online presence, ensuring convenient store locations and leveraging digital platforms for increased accessibility. Promotion strategy, on the other ...
With the rise of digitalization, there's a growing need for a comprehensive platform that can bridge offline and online services, catering to the diverse needs of students and the campus community....
- **State Definitions**: Descriptions of each state, such as "Online," "Offline," and "Degraded." - **Transition Rules**: Guidelines on how states transition based on events within the cluster. - *...
an online multi-camera spatial-temporal data association method for tracking large groups of objects imaged with low resolution. As a variant of the well-known Multiple- Hypothesis-Tracker, our ...
7. **online/offline**:这些事件分别在设备网络状态变为在线和离线时触发,可以帮助开发者检测并适应网络状况变化。 以下是一个简单的示例,展示了如何使用 PhoneGap 的 'deviceready' 和 'backbutton' 事件: ``...
See DbConverter.[+] Impoved SMS support, see OnSMSAck & OnSMSRefused events.[-] TICQDb: .idx and .dat files were not closed after importing[-] Offline messages were not received (Thx to Sergey ...
* When using RefreshRecord on a Memo or Blobfield and the field has been modified by another user, the blobsize of that field does not change if it is less than before (Quality Central 4676).* ...
string1 sets the window title and string2 the process name (on Linux) -uuid x-x-x-x-2x specify machine UUID Display options: -display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off] [,...
下面的PrivacyLevel ,第一格 (Anyone m ay contact me when I am online)是指: 您的UIN 开放给任何 人加入联络名单,不 需经过您的同意;而 第二格(my authori zation is required ) 则是任何人要将您 加入名单时...
- **`user_online_presence`**:获取用户是否在线。 - **`user_photo_video_tags`**:获取用户被标记的照片和视频。 - **`user_photos`**:获取用户的个人照片。 - **`user_relationships`**:获取用户的关系状态。 ...