Welcome to WebmasterWorld Guest from 23.20.75.214

Forum Moderators: open

Message Too Old, No Replies

Change print layout to landscape

For IE7 & Firefox

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 13, 2002
posts:2162
votes: 0


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

Thanks.


<script type="text/javascript">
var shell;
function SetPrintProperties() {
try {
shell = new ActiveXObject("WScript.Shell");
shell.SendKeys("%fu");
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() {
shell.sendKeys("%a{TAB}.2{TAB}0{TAB}0{TAB}0{ENTER}");
}
function setLandScape() {
shell.sendKeys("%fp");
window.print();
}
</script>
<body onload="SetPrintProperties()">
9:22 am on Oct 2, 2007 (gmt 0)

Preferred Member

5+ Year Member

joined:May 29, 2007
posts: 578
votes: 0


Try using CSS rather than javascript

See:
[w3.org...]
[meyerweb.com...]

____________________________________

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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 13, 2002
posts:2162
votes: 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)

Preferred Member

10+ Year Member

joined:July 5, 2005
posts:352
votes: 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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 13, 2002
posts:2162
votes: 0


Hi
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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 26, 2004
posts:1497
votes: 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'.