【发布时间】:2017-08-16 15:14:27
【问题描述】:
我无法让它工作。我唯一需要的 - 将所有内容字体系列设置为'Open Sans'。这是我现在拥有的
var popupWin = window.open('', '_blank', 'width="100%",height="100%"');
popupWin.document.write('<html><head><link href=\'http://fonts.googleapis.com/css?family=Open+Sans\' rel=\'stylesheet\' type=\'text/css\'></head><body>' + content + '</body></html>');
popupWin.document.body.setAttribute('style', 'font-family: \'Open Sans\' !important');
popupWin.document.close();
popupWin.print();
popupWin.close();
}
这段代码显示空白页面,但是当我删除link 属性时,内容正在显示,但带有默认系列。有什么想法吗?
附:内容变量包含一个简单的 html 标记,我试图设置样式像
<div style="font-family='Open Sans'">
但没有运气。
【问题讨论】:
-
您是从 HTTPS 选项卡打开页面吗?如果是这样,浏览器将阻止您对“http://....”的请求。尝试删除协议
href=\'//fonts.googleapis.com/css?family=Open+Sans\' -
是的,我使用的是 HTTPS,但是如何删除协议,Open Sans 不是标准字体,我必须上传它
-
评论告诉你怎么做。只需从
href属性的开头删除http:(保留斜线)即可。 -
这只是一个空白屏幕,没有显示任何内容
标签: javascript printing font-family