navigate-iframe.html (887B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <script src="/cookies/resources/cookie-helper.sub.js"></script> 4 <script> 5 window.addEventListener('load', function() { 6 window.opener.postMessage({ type: 'LOADED' }, '*'); 7 }); 8 9 window.addEventListener('message', function(e) { 10 if (SECURE_ORIGIN !== window.location.origin) 11 return; 12 13 if (e.data.type === "initialize-iframe") 14 window.frames[0].location = e.data.url; 15 if (e.data.type === "navigate-iframe") 16 window.frames[0].postMessage({ type: 'navigate', url: e.data.url }, '*'); 17 18 // Relay messages sent by the subframe to the opener. 19 if (e.data.type === 'FRAME_READY') 20 window.opener.postMessage({ type: 'FRAME_READY' }, '*'); 21 22 if (e.data.type === 'FRAME_COOKIES_SET') 23 window.opener.postMessage({ type: 'FRAME_COOKIES_SET', cookies: e.data.cookies }, '*'); 24 }); 25 </script> 26 <iframe></iframe>