<div id="email_content">
<iframe srcdoc="{$email_content}"></iframe>
</div>
如下图所示,我正在使用div#email_content
中的iframe来显示电子邮件内容的精确预览。我正在尝试使用srcdoc
属性在iframe中加载电子邮件内容。这里的电子邮件内容可以是纯文本或通过CkEditor设计的HTML内容。我尝试使用转义、htmlentities等,但是srcdoc属性中断了,因为属性值包含纯HTML代码和引号。
将接受任何变通方法。
谢谢!
注意:我不想在这里使用src
属性。
发布于 2017-11-25 13:24:16
你需要在php中使用htmlentities
方法。
<?php
$str = '<a href="https://www.tarunlalwani.com">Go to tarunlalwani.com</a>';
echo htmlentities($str);
?>
然后将其分配给srcdoc
。它的工作方式如下面的JSFiddle所示
https://stackoverflow.com/questions/33338962
复制相似问题