Home > OS >  iFrame not showing inline HTML content
iFrame not showing inline HTML content

Time:05-22

I have an iFrame on my site, and instead of using an src attribute, I want to show inline HTML within the iFrame. Is there any way I can do this? Example:

<iframe><p>Hello World</p></iframe>

Should show text saying "Hello World" within an iFrame, but shows this instead:

<iframe><p>Hello World</p></iframe>

CodePudding user response:

Use the srcdoc attribute.

<iframe srcdoc='<img src="https://i.ibb.co/7XxsBr5/lena02.png" alt="lena02" border="0" width="100">' height='150' width='150'></iframe>

  • Related