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

267
Visualizações
How to do communication between I-Frame and parent window in angular

Any suggestion How to make Iframe communicate to parent window. Scenario :

Inside Iframe there is separate website in same domain having multiple links. When user clicks on Link inside iframe the value should propagate to parent window.

I tried tracking the click event inside Iframe and getting iFrame.src but it didnt work.

HTML :

 <iframe #Iframe class="iframek" (click)="onChange(kIframe)" sandbox="allow-same-origin allow-scripts allow-top-navigation" id="iframe_k"   [src]='safeUrl' scrolling="auto" frameborder="0" allowfullscreen=true wmode="transparent" name="kiframe"></iframe>

onChange(iframe) {
  console.log("onchange");
  if(iframe.contentWindow)
  {
    console.log(iframe.contentWindow.document);
  }
  else{
    console.log(iframe.contentWindow);
  }
  
  console.log(iframe.getAttribute('src'));
  
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should use cross-origin communication between Window objects.

See this answer for details: How to communicate between iframe and the parent site?.

To implement your scenario, do the following:

  1. Track all click events on anchors in the iframe
  2. After clicking, read the href attribute of the clicked anchor and send it to the parent window using window.postMessage() (remember to call preventDefault() on the click event to prevent navigation inside iframe)
  3. Receive the event in the parent window and navigate
about 4 years ago · Juan Pablo Isaza Relatório
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