focusin.html (1700B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title> W3C DOM Level 3 Event: focusin </title> 5 <script type="text/javascript"> 6 var PassTest = function() 7 { 8 document.getElementById("testresult").firstChild.data = "PASS"; 9 } 10 11 var FailTest = function() 12 { 13 document.getElementById("testresult").firstChild.data = "FAIL"; 14 } 15 16 var EVENT = "focusin"; 17 var TARGET, PARENT; 18 19 window.onload = function() 20 { 21 try 22 { 23 TARGET = document.getElementById("target"); 24 PARENT = document.getElementById("parent"); 25 26 PARENT.addEventListener(EVENT, TestBubble, false); 27 } 28 catch(ex) 29 { 30 FailTest(); 31 } 32 } 33 34 function TestBubble(evt) 35 { 36 if ((evt.type == EVENT) && (evt.currentTarget == PARENT) && (evt.target == TARGET)) 37 { 38 PassTest(); 39 } 40 else 41 { 42 FailTest(); 43 } 44 } 45 </script> 46 </head> 47 <body> 48 <h4> 49 Test Description: 50 focusin event fires when an event target is about to receive focus. 51 </h4> 52 53 <div id="parent"> 54 Click here: <input id="target" /> 55 </div> 56 57 <p>Test passes if the word "PASS" appears below after clicking the above textbox using mouse.</p> 58 <div>Test result: </div> 59 <div id='testresult'>FAIL</div> 60 </body> 61 </html>