focus-restoration-in-different-site-iframes-inner.html (739B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Inner document</title> 6 </head> 7 <body> 8 <h1>Inner</h1> 9 <input type="text"> 10 <script> 11 window.onmessage = function(e) { 12 if (e.data == "getlog") { 13 parent.postMessage(log, "*"); 14 } 15 }; 16 17 let log = "log:"; 18 let input = document.getElementsByTagName("input")[0]; 19 input.onfocus = function() { 20 log += "inputfocus," 21 } 22 input.onblur = function() { 23 log += "inputblur," 24 } 25 document.body.onfocus = function() { 26 log += "bodyfocus," 27 } 28 document.body.onblur = function() { 29 log += "bodyblur," 30 } 31 window.onload = function() { 32 log += "willfocusinput," 33 input.focus(); 34 log += "didfocusinput," 35 parent.postMessage("start", "*"); 36 } 37 </script> 38 </body> 39 </html>