focusin.relatedTarget.html (1855B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title id='desc'> FocusEvent.relatedTarget for focusin Event </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, HELPER; 18 19 window.onload = function(e) 20 { 21 try 22 { 23 TARGET = document.getElementById("target"); 24 HELPER = document.getElementById("helper"); 25 TARGET.addEventListener(EVENT, TestEvent, true); 26 } 27 catch(ex) 28 { 29 FailTest(); 30 } 31 } 32 33 function TestEvent(evt) 34 { 35 if ((evt.target == TARGET) && (evt.relatedTarget == HELPER)) 36 { 37 PassTest(); 38 } 39 else 40 { 41 FailTest(); 42 } 43 } 44 </script> 45 </head> 46 <body> 47 <h3>DOM Events</h3> 48 <h4> 49 Test Description: FocusEvent.relatedTarget for focusin event is the event target losing focus. 50 </h4> 51 52 <pre> 53 <input id="helper" value="" /> <button id="target">BUTTON</button> 54 55 Steps: 56 1) Click in the above textbox using mouse 57 2) Then click the above button using mouse 58 </pre> 59 60 <p>Test passes if the word "PASS" appears below after following the above steps.</p> 61 <div>Test result: </div> 62 <div id='testresult'>FAIL</div> 63 </body> 64 </html>