`
sohighthesky
  • 浏览: 35780 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Online and offline events

阅读更多
<!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

    How Online Social Network Affects Offline Events A Case Study on Douban

    online-offline-budget-trackers

    在技术实现上,"online-offline-budget-trackers"很可能是利用了现代Web技术,尤其是JavaScript,来构建前端界面和处理用户的交互。JavaScript是Web开发中的关键语言,用于动态更新网页内容,创建交互式用户体验。在...

    基于ssm+mysql羽毛球馆管理系统源码数据库论文.doc

    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 ...

    Corodova-Network-Events:使用navigator.online fallback检索Cordova网络信息

    当连接状态从脱机状态更改为联机状态时,将cordova.network.online 。 或者,当设备或浏览器脱机时,将触发cordova.network.offline 。 如果您喜欢这样工作,这两个事件使您可以收听事件。 最后,作为第三个替代...

    jQueryProxyMobilePhonegapBuild:使用 jQuery moibile 多屏幕的示例和之前应用中的 index.js 代码

    JQuery Mobile 应用程序对象和事件你会看到很多类似... Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDevice

    金来福连锁超市营销策略存在的问题及对策浅析.docx

    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 ...

    基于大数据分析的精准智能服务平台设计——“校叮当”小程序开发.pdf

    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....

    VCS Tech Talk

    - **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. - *...

    occlusion reasoning for multiple object tracking

    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 ...

    PhoneGap,API帮助文档翻译整理7-Events_(消息)

    7. **online/offline**:这些事件分别在设备网络状态变为在线和离线时触发,可以帮助开发者检测并适应网络状况变化。 以下是一个简单的示例,展示了如何使用 PhoneGap 的 'deviceready' 和 'backbutton' 事件: ``...

    TICQClient Version

    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 ...

    Delphi7.1 Update

    * 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).* ...

    Qemu-1.0.1 for windows

    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] [,...

    icq6英文版 最新

    下面的PrivacyLevel ,第一格 (Anyone m ay contact me when I am online)是指: 您的UIN 开放给任何 人加入联络名单,不 需经过您的同意;而 第二格(my authori zation is required ) 则是任何人要将您 加入名单时...

    Facebook Oauth2.0 API提供接口集

    - **`user_online_presence`**:获取用户是否在线。 - **`user_photo_video_tags`**:获取用户被标记的照片和视频。 - **`user_photos`**:获取用户的个人照片。 - **`user_relationships`**:获取用户的关系状态。 ...

Global site tag (gtag.js) - Google Analytics