开发者

Use JavaScript to print HTML page in landscape format

开发者 https://www.devze.com 2023-01-24 14:36 出处:网络
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 y

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"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消