我必须在 window.open() 的新窗口中更改字体,因为我想在收据打印机中打印。我已经更改了 True Type 字体替换,但它不起作用。那么如何为新打开的窗口添加 css 呢? 这是我的代码:
<img src="barcode.png" id="barcode">
<script type="text/javascript">
function printImg() {
ImageLink=document.getElementById("barcode").src;
pwin=window.open('','','width=0,height=0');
pwin.document.write("<center><h>My Store<h><br>Ekiosk</center><br>Date : <?php echo date('Y/m/d'); ?><br>Time : <?php echo date('H:i:s'); ?><br>Customer Name: <?php echo $cust['firstname']; ?> <?php echo $cust['lastname']; ?> <br>Total : <?php echo $cust['total']; ?><br><center><img src='" + ImageLink + "'/><br>Thanks For Shopping !</center>");
pwin.print();
pwin.close();
}
</script>
谁能帮我把字体改成收据字体?
最佳答案
添加一个CSS文件
<link href="your.css" ... />
就像你在处理你的pwin.document.write
句子一样
您还应该在 document.write 中编写完整的有效 html 代码,包括 html、title、head 和 body 标签,并将链接放在 head 标签内,就像您在任何其他页面中所做的那样。
关于html - 如何更改 innerHTML 新窗口中的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17782601/