iframe-activeelement-after-focusing-out-iframes-inner.html (794B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>iframe active element inner document</title> 6 </head> 7 <body> 8 <h1>Inner</h1><br> 9 <input></input> 10 <script> 11 let innerlog = "innerlog:"; 12 13 window.onmessage = function(e) { 14 if (e.data == "getlog") { 15 parent.postMessage(innerlog, "*"); 16 } 17 }; 18 19 window.onfocus = function() { 20 innerlog += "windowfocus,"; 21 }; 22 23 window.onblur = function() { 24 innerlog += "windowblur,"; 25 innerlog += "activeElement:" + document.activeElement.tagName + ","; 26 }; 27 28 let input = document.querySelector("input"); 29 window.onload = function() { 30 innerlog += "willfocusinput,"; 31 input.focus(); 32 innerlog += "didfocusinput,"; 33 innerlog += "activeElement:" + document.activeElement.tagName + ","; 34 parent.postMessage("ready", "*"); 35 }; 36 </script> 37 </body> 38 </html>