我的 html 位于 php 变量中,例如 $html,我想使用 javascript 打印此 html。我为此编写了以下代码。
<script>var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write(<?= $html ?>);
mywindow.print();</script>
如果变量包含普通字符串而不是HTML
,它对我有用最佳答案
尝试在 write 函数中使用引号,例如,
mywindow.document.write("<?= $html ?>");
关于javascript - 使用 php 变量和 javascript 打印 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38717378/