homepage Welcome to WebmasterWorld Guest from 54.198.148.191
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

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
aspdaddy




msg:3466751
 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?

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




msg:3466801
 9:22 am on Oct 2, 2007 (gmt 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;
}

____________________________________

aspdaddy




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

Trace




msg:3466957
 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.

aspdaddy




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

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

Robin_reala




msg:3467193
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved