Skip to content

Instantly share code, notes, and snippets.

@davidpelaez
Created April 22, 2013 18:59
Show Gist options
  • Select an option

  • Save davidpelaez/5437556 to your computer and use it in GitHub Desktop.

Select an option

Save davidpelaez/5437556 to your computer and use it in GitHub Desktop.
receiveMessage = (event)->
# Do we trust the sender of this message? (might be
# different from what we originally opened, for example).
#return if (event.origin !== "http://example.org")
# event.source is popup
# event.data is "hi there yourself! the secret response is: rheeeeet!"
console.log "iframe:", event.data
window.addEventListener "message", receiveMessage, false
window.onload = ->
console.log "[potential] IFRAME LOADED!"
w = window
#while ((w = w.parent) && (window.top !== w))
if parent is window
console.log "THIS IS NOT in IFRAME"
else
parent.postMessage('vlipco:checkout:ready','*')
console.log "I'm an IFRAME!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment