Html code as IFRAME source rather than a URL

You can use srcdoc attribute to include HTML Code to Iframe.

<iframe srcdoc="<html><body>Hello, <b>world</b>.</body></html>"></iframe>

For JSF as htmlCode is the code as String
<iframe srcdoc="${bean.htmlCode}"></iframe>

If your HTML contains double quotes, consider escaping its double quotes

Leave a comment