focus-restoration-in-same-site-iframes-inner-window.html (547B)
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 <script> 10 window.onmessage = function(e) { 11 if (e.data == "getlog") { 12 parent.postMessage(log, "*"); 13 } 14 }; 15 16 let log = "log:"; 17 window.onfocus = function() { 18 log += "windowfocus," 19 } 20 window.onblur = function() { 21 log += "windowblur," 22 } 23 window.onload = function() { 24 log += "willfocuswindow," 25 window.focus(); 26 log += "didfocuswindow," 27 parent.postMessage("start", "*"); 28 } 29 </script> 30 </body> 31 </html>