Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
bressler95tops authored Sep 26, 2024
1 parent 732b75b commit 7271ee8
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ <h1>iFrame Host</h1>
function init_iframe() {
var iframe = document.createElement('iframe');
iframe.onload = function() {
let receiver = document.getElementById("receiver");
console.log(receiver);
inject_data(receiver);

const cookie_value = localStorage.getItem("cookie_value");
console.log("Attempting to initialize iframe value with local storage: " + cookie_value);

if(cookie_value != null) {
this.contentWindow.postMessage(cookie_value, '*');
}
};

iframe.src = 'https://iframehost.pages.dev';
Expand All @@ -39,15 +43,6 @@ <h1>iFrame Host</h1>
}

init_iframe();

function inject_data(receiver) {
const cookie_value = localStorage.getItem("cookie_value");
console.log("Attempting to initialize iframe value with local storage: " + cookie_value);

if(cookie_value != null) {
receiver.contentWindow.postMessage(cookie_value, '*');
}
}

});
</script>
Expand Down

0 comments on commit 7271ee8

Please sign in to comment.