homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Change print layout to landscape
For IE7 & Firefox

 8:01 am on Oct 2, 2007 (gmt 0)

Hi, this code works fine on IE5&6 does anyone know how to achieve the same on IE7 & Firefox?


<script type="text/javascript">
var shell;
function SetPrintProperties() {
try {
shell = new ActiveXObject("WScript.Shell");
window.setTimeout("javascript:SetPaperSize();", 1200);
window.setTimeout("javascript:setLandScape();", 2000);
} catch (e) {
alert('Please verify that your print settings have a Landscape orientation and minimum margins.');
function SetPaperSize() {
function setLandScape() {
<body onload="SetPrintProperties()">



 9:22 am on Oct 2, 2007 (gmt 0)

Try using CSS rather than javascript



In the <head>:
<link rel="stylesheet" type="text/css" media="print" href="myCssFolder/myPrintFile.css">


In myPrintFile.css:

* {
size: landscape;



 11:09 am on Oct 2, 2007 (gmt 0)

That doesnt work in IE6,7 or Firefox.

Weve done some research on the various approaches, & the code I posted is the best way found to change the print orientation to landscape & set the margins. The only problem is it doesnt work on IE7 & Firefox :(


 1:05 pm on Oct 2, 2007 (gmt 0)

I would be very worried if a web page could change the default settings of my browser like that.

I guess you could transform the content and flip it 90 degrees using JavaScript but I assume once actually printed it would look horrible especially with images.


 2:31 pm on Oct 2, 2007 (gmt 0)

Tried that also, the transform / rotate doesnt work well with small text in table cells,some of it is unreadable.


 4:57 pm on Oct 2, 2007 (gmt 0)

I've had a look around at the various CSS3 printing specs and setting to landscape seems to be restricted to an entire document, not individual pages. Even then, browser support is going to be minimal at best, If you want fine-grained print support then you probably want to consider exporting to PDF on the backend and adding that to the page as a 'printable version'.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved