Last active
July 1, 2016 17:39
-
-
Save ccnixon/8957c7910bce6e225bc04efbc40b18de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe id="verse-media-destination-frame" src="https://VERSE-MEDIA-PLAYER-IFRAME-URL"></iframe> | |
<script> | |
//Function to read value of a cookie | |
function readCookie(name) { | |
var cookiename = name + "="; | |
var ca = document.cookie.split(';'); | |
for(var i=0;i < ca.length;i++) { | |
var c = ca[i]; | |
while (c.charAt(0)==' ') c = c.substring(1,c.length); | |
if (c.indexOf(cookiename) == 0) return c.substring(cookiename.length,c.length); | |
} | |
return null; | |
} | |
//Call readCookie function to get value of user's Marketo cookie | |
var marketoTrackingId = readCookie('_mkto_trk'); | |
// Gets a reference to the window object of the destination iframe. | |
var frameWindow = document.getElementById('verse-mediadestination-frame').contentWindow; | |
// Sends the client ID to the window inside the destination frame. | |
frameWindow.postMessage(marketoTrackingId, 'https://verse-media-video-player.com/video121312'); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('message', function(event) { | |
// Ignores messages from untrusted domains. | |
if (event.origin != 'https://VERSE-MEDIA-PLAYER-IFRAME-URL') return; | |
window.marketoTrackingId = event.data | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment