2009/dap/system-info battery-status.html,1.3,1.4

Update of /sources/public/2009/dap/system-info
In directory hutz:/tmp/cvs-serv14674

Modified Files:
	battery-status.html 
Log Message:
onbatterystatus event handler; updated examples

Index: battery-status.html
===================================================================
RCS file: /sources/public/2009/dap/system-info/battery-status.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- battery-status.html	6 Apr 2011 17:38:35 -0000	1.3
+++ battery-status.html	7 Apr 2011 11:55:24 -0000	1.4
@@ -165,14 +165,21 @@
       <p>
         If a change in the battery status of the hosting device occurs,
         then the User Agent MUST dispatch a <a>BatteryStatusEvent</a>
-        event on the <code>window</code> object.
+        event on the <code>Window</code> [[!HTML5]] object.
       </p>
       <p>
         If a change in the battery status of an auxiliary device occurs,
         and the auxiliary device is exposed on <code>o</code> object, and
-        the <code>o</code> implements the <code>EventTarget</code> interface,
-        then the User Agent MUST dispatch a <a>BatteryStatusEvent</a> event on
-        the <code>o</code> object.
+        the <code>o</code> implements the <code>EventTarget</code>
+        [[!DOM-LEVEL-3-EVENTS]] interface, then the User Agent MUST dispatch a
+        <a>BatteryStatusEvent</a> event on the <code>o</code> object.
+      </p>
+      <p>
+        The <code>onbatterystatus</code> event handler MUST be supported by
+        <code>Window</code> objects, as an IDL attribute on the
+        <code>Window</code> object. Similarly, as an IDL attribute on the
+        <code>o</code> object, if it fulfill the conditions given in the
+        "change in the battery status of an auxiliary device".
       </p>
       <p>
         If an event listener is registered with the event type
@@ -209,7 +216,10 @@
     <section class='informative'>
       <h2>Examples</h2>
       <p>
-        Register to receive repeated <a>BatteryStatusEvent</a> events:
+        Register to receive repeated <a>BatteryStatusEvent</a> events.
+      </p>
+      <p>
+        By using the <code>addEventListener()</code> method:
       </p>
       <div class='example'>
         <pre class='sh_javascript'>
@@ -219,18 +229,42 @@
         </pre>
       </div>
       <p>
-        Register to receive a single <a>BatteryStatusEvent</a> event:
+        By assigning a function to the <code>onbatterystatus</code> property:
+      </p>
+      <div class='example'>
+        <pre class='sh_javascript'>
+window.onbatterystatus = function (event) {
+  console.log(event.level);
+};
+        </pre>
+      </div>
+      <p>
+        Register to receive a single <a>BatteryStatusEvent</a> event.
+      </p>
+      <p>
+        By using the <code>addEventListener()</code> method:
       </p>
       <div class='example'>
         <pre class='sh_javascript'>
 var handler = function (event) {
   console.log(event.level);
   window.removeEventListener('batterystatus', handler, true);
-}
+};
 
 window.addEventListener('batterystatus', handler, true);
         </pre>
       </div>
+      <p>
+        By assigning a function to the <code>onbatterystatus</code> property:
+      </p>
+      <div class='example'>
+        <pre class='sh_javascript'>
+window.onbatterystatus = function (event) {
+  console.log(event.level);
+  window.onbatterystatus = null;
+};
+        </pre>
+      </div>
     </section>
     
     <section class='appendix'>

Received on Thursday, 7 April 2011 11:55:27 UTC