I want to use JavaScript to print开发者_JAVA百科 an HTML page in the landscape format.
AFAIK, that's not possible, your page will be printed how it is made. Having said that, you can use CSS to make your page in landscape view.
@page {
size: landscape;
}
As for IE, check out this post:
- using css to force Landscape Print in IE
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script><script language="javascript" type="text/javascript"> function JPrint(){
// Create the WScript
var objWScriptShell = new ActiveXObject("WScript.Shell");
// Send Keys
objWScriptShell.SendKeys("(%f)u");
// Change to landscape
objWScriptShell.SendKeys("(%a)");
objWScriptShell.SendKeys("~");
// Enter O.K.
setTimeout("window.print()",500);
}</script><input onclick="javascript:void(JPrint())" type="button" value="Print Page"/>
精彩评论