Welcome to WebmasterWorld Guest from 54.196.233.239

Forum Moderators: open

Message Too Old, No Replies

Change print layout to landscape

For IE7 & Firefox

     

aspdaddy

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

WebmasterWorld Senior Member 10+ Year Member



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()">

lavazza

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

5+ Year Member



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;
}

____________________________________

aspdaddy

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

WebmasterWorld Senior Member 10+ Year Member



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 :(

Trace

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

10+ Year Member



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.

aspdaddy

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

WebmasterWorld Senior Member 10+ Year Member



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

Robin_reala

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

WebmasterWorld Senior Member 10+ Year Member



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'.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month