blur.html (1635B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title> W3C DOM Level 3 Event: blur </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 = "blur"; 17 var TARGET; 18 19 window.onload = function() 20 { 21 try 22 { 23 TARGET = document.getElementById("target"); 24 TARGET.addEventListener(EVENT, TestCapture, true); 25 } 26 catch(ex) 27 { 28 FailTest(); 29 } 30 } 31 32 function TestCapture(evt) 33 { 34 if ((evt.type == EVENT) && (evt.currentTarget == TARGET)) 35 { 36 PassTest(); 37 } 38 else 39 { 40 FailTest(); 41 } 42 } 43 </script> 44 </head> 45 <body> 46 <h4>Test Description: blur event fires when an event target loses focus.</h4> 47 48 <div id="parent"> 49 Click the textbox and then the button: <br /> 50 <input id="target" /> <button id="helper">Button</button> 51 </div> 52 53 <p>Test passes if the word "PASS" appears below after clicking the above textbox and then the button.</p> 54 <div>Test result: </div> 55 <div id='testresult'>FAIL</div> 56 </body> 57 </html>