Passing variable from unbounce landing page to iframe popup?


I have an unbounce landing page that I am trying to pass a variable that is stored in SessionStorage to the native unbounce popup. Since the popup shows as an iFrame, I am trying to use postMessage in JavaScript to send that variable but it doesn’t seem to be working for me. Has anyone successfully managed to do this?

To clarify, I have seen a bunch of stuff sending variables from the popup to the parent page but not the other way around. Any help would be much appreciated!

Thank you!

2 replies

Userlevel 7
Badge +3

Hi @gr8hoops21

What are the 2 scripts you are using? 



Hi @Hristian,

I think I am doing it backwards right now but here is the code:

Landing Page JS:

// This will need to be specific to the URL for your popup
const popupOrigin = "";

// On receiving message from the Convertable set a cookie
window.onload = function () {
function handleMessage (e) {
var eventData = JSON.stringify(;

if (e.origin.includes(popupOrigin)) {
// Check for the message
if (eventData === 'variable') {
// do whatever you need with the variable

// Listen for the message from the popup
window.addEventListener('message', handleMessage);

iFrame Popup JS:

const buttonId = "#lp-pom-button-51";
const hostDomain = "*";

document.querySelector(buttonId).onclick = function () {"variable"), hostDomain);

I have a button on the iFrame popup with that ID.


Could it potentially have any thing to do with the popup not showing up until 3 seconds after the page loads?