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

228
Visualizações
How to let iframe element know that the content being passed to it is xml

I'm working on retrieving some xhtml content at run time and displaying that within an iframe element of an html page. The problem which I'm trying to solve here is the title tag which is part of the xhtml content is being passed as a self closing tag (<title/>) and when the content is passed into iframe, it is being consumed as html which is resulting in the content not being displayed at all within iframe.

Adding a screenshot of the dom below for reference: enter image description here

Please note that when I am trying to consume the xhtml content after storing it as a separate xhtml file and retrieving it using the src tag (specifying the path to the same), the xml parsing is correctly done and I could see the text content being displayed as well. But unfortunately, the content is actually getting generated in real time in the real scenario where I'm trying to fix it so using src attribute is not an option.

I also tried accessing the contentDocument of the iframe and adding the xml content directly there but even that doesn't seem to be solving the problem.

Does somebody know of any workaround for addressing this problem?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The srcdoc attribute assumes "text/html" content type. Consider using the src attribute with a data: url like this:

<iframe src="data:application/xhtml+xml,
   <html xmlns='http://www.w3.org/1999/xhtml'>
     <head>
       <title/>
     </head>
     <body>
       <p>Hello world</p>
     </body>
   </html>">
</iframe>

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