作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我想更改窗口打印的纸张模式(方向)。我想以编程方式更改它,但我找不到任何东西。
window.print()
但我不知道,我该怎么做。
@media print{@page {size: landscape}}
我不需要它。
function printWindow()
{
window.print({
/*
some code here?
*/
});
}
最佳答案
您需要为文档注入(inject)样式。
var css = '@page { size: landscape; }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
style.media = 'print';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
window.print();
//don't forget to find and remove style if you don't want all you documents stay in landscape
关于javascript - 更改 Window.print() 纸张方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39025840/
我正在尝试在我的 1.0 polymer 元素之一中实现纸张 slider ... 我得到的错误是: Uncaught TypeError: this.has
我还是 Vaadin 的新手,我正在尝试使用 Vaadin 14 实现 @polymenr/paper-slider 组件。 我已经下载了项目https://github.com/berndhopp/
我还是 Vaadin 的新手,我正在尝试使用 Vaadin 14 实现 @polymenr/paper-slider 组件。 我已经下载了项目https://github.com/berndhopp/
我正在尝试像这样实现页面 curl : 我遵循了这个例子:http://codepen.io/anon/pen/fpjoa 如果我创建新的 PHP 和 CSS 文件并从上面的链接复制粘贴代码,结果是正
我是一名优秀的程序员,十分优秀!