我有我的PHP变量中的HTML说$ html,我想用javascript打印此html。我为此写了下面的代码。使用PHP变量和javascript打印HTML
<script>var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write(<?= $html ?>);
mywindow.print();</script>
它为我,如果变量包含正常的字符串不HTML
你的代码没有错误。我个人现在跑它,它的工作原理。 –