html - 如何更改 innerHTML 新窗口中的字体?

标签 html css fonts receipt

我必须在 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/

相关文章:

html - CSS - 样式不继承属性

html - 试图使 div 居中

html - 如何为 WebKit(Chrome、Safari)的表格单元格设置 50% 高度

html - div 和 img float :left in IE7 的 CSS 对齐问题

html - 如何让表格单元格根据内容收缩?

javascript - 如何在 jquery 中向上滑动带有移动效果的容器?

c# - 从文件系统中的字体加载家族(而不是字体)名称

Firefox 中的 CSS Google 字体问题

c# - 如何获得所有已安装的固定宽度字体?

javascript - clearInterval 不重置