Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
iframe receives message from parent window but console.log returns [object MessageEvent]

I'm sending messages from the parent window to the iframe, but when I log the message inside the iframe, it returns [object MessageEvent].

I've tried to parse it with JSON.parse and it produces a parse error, but when I try JSON.stringify it prints the string representation of the message correctly.

Can I access the object without doing JSON.strinfigy?

From the Parent window, I'm not sending JSON string. I'm sending an object.

Below is my code in parent window

frame.contentWindow.postMessage({
  action: 'start', 
  config: {onlyWithImages}
}, '*')

and inside the iframe I've this code

window.addEventListener('message', e => {
  let data = e.data
  console.log(data) //[object MessageEvent]
}
about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda