我们可以从客户端默认打印到横向吗? [英] Can we default the Print to Landscape from client side?
本文介绍了我们可以从客户端默认打印到横向吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个在点击上打印我的ASPX页面的功能,它非常完美。
Here is a function that prints my ASPX page on a click which works absolutely perfect .
function PrintPanel() {
debugger;
var panel = document.getElementById("<%=Upnl1.ClientID %>");
var printWindow = window.open(panel, '', 'height=600,width=900');
printWindow.document.write('<html><head><title>DIV Contents</title>');
printWindow.document.write('</head><body >');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
setTimeout(function () {
printWindow.print();
}, 1000);
return false;
}
但是我想简单的事情就是我被卡住的地方。我希望它默认在横向打印。 Always Printer选择了Potrait。但我想做这个横向而不是用户选择它,我更喜欢它默认为横向这个功能单独使用。
有人可以帮帮我吗?
But I want to simple thing which is where I am stuck. I want it to print in Landscape by default. Always Printer picks the Potrait. But I want to do this Landscape instead of user picking it , I prefer it to default to Landscape for this function alone.
Can someone help me with this please?
推荐答案
你不能从中选择默认方向你的javascript代码。在浏览器中运行的代码在受限制的沙箱中运行。浏览器本身和所有系统资源都是你的代码的禁区。
You can't select the default orientation from your javascript code. Code running inside the browser runs inside a restricted sandbox. The browser itself and all system resources are off-limits to your code.
这是不可能的:-)
你能做什么,是轻轻地强迫用户通过调整输出形式的尺寸来打印横向输出。然而:一个精明的用户仍然可以绕过这个。
That's impossible :-)
what you could do, is "gently" force the user to print the output in landscape, by indeed adjusting the dimensions of your output-form. Nevertheless : a savvy user would still be able to circumvent this.
这篇关于我们可以从客户端默认打印到横向吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文