DOS Games Message Board
DOS Games Discussion
A message board to talk about DOS games, get help, and find old games.
Do NOT post warez or abandonware requests please
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Controlling browser's print options with JavaScript?

 
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> General Off-Topic
Author Message
KAN
Experienced Member
Experienced Member


Offline
Joined: 28 Jul 2005
Posts: 72
Location: Indonesia

PostPosted: Tue Dec 02, 2008 4:19 am     Post subject: Controlling browser's print options with JavaScript? Reply with quote

Although each browser's print options is different (for example, "Print Options" in Opera, and "Page Setup" in Internet Explorer), it seems they handle similar set of parameters, like:
- header and footer
- print margins
- paper size and orientation

Could I control those browser's parameters with JavaScript? Or better, with CSS? Internet Explorer is particularly annoying by enabling header and footer by default. Could I, for instance, write a JavaScript to disable browser's header and footer?

I'm also writing a web-based application that are supposed to print pages in exact size (A4, etc). I try to achieve the HTML page size by the following:
Code:
<html>
<head>
</head>
<body>
<table border=1 style="width:29.7cm;height:21cm";border-color:black">
<tr><td>A4</td></tr>
</table>
</body>
</html>


The code above give me exact A4 page size on screen, especially since I disable HTML page margin (<body>). Alas, when printing, the browser's margins still exist, ruining the print result. Is it possible to set browser's margins to zero (all of them; Top, Bottom, Left, Righ) using JavaScript?
Back to top
wardrich
lawl catz r lawlz
lawl catz r lawlz


Offline
Joined: 14 Sep 2002
Posts: 3361
Location: Ontario Canada

PostPosted: Tue Dec 02, 2008 5:15 am     Post subject: Reply with quote

I could see how something like this could be taken for evil... especially if there's a way to bypass all user interaction. Malevolent
Back to top
fauvem
Expert
Expert


Offline
Joined: 14 Aug 2006
Posts: 152
Location: A non-specific pacific island

PostPosted: Tue Dec 02, 2008 6:39 am     Post subject: Reply with quote

I'm quilty of such evilness but in a different scripting language. I'll see if the code is still floating around.
Back to top
AdamN
Lord of Gaming
Lord of Gaming


Offline
Joined: 29 Oct 2006
Posts: 265
Location: in your basement with a blood-covered axe

PostPosted: Sun Dec 14, 2008 4:06 am     Post subject: Reply with quote

To my knowledge, Javascript can't read hardware or peripheral devices to print a page with a specific paper size, nor can it remove the header or footer of the page you are printing, the easiest option would be to put a download of a printable document on your site, where users can download the document and print it without the headers and footers.

However, try this in CSS:

Code:

body { background-colour:#EFEFEF;
           margin:0px auto !important;
           padding:0px auto !important;}
#A4 {background-color:#FFFFFF;
        left:200px;
        right:190px;
        height:297mm !important;
        width:210mm !important;
        margin:1px solid #FFFFFF; }


and add it in HTML with this:

in body type
Code:
 <div id="A4"></div>


save and test.
Back to top
KAN
Experienced Member
Experienced Member


Offline
Joined: 28 Jul 2005
Posts: 72
Location: Indonesia

PostPosted: Sun Dec 14, 2008 5:09 am     Post subject: Reply with quote

Thanks! I'll definitely try.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    DOS Games Discussion Forum Index -> General Off-Topic All times are GMT - 5 Hours
Page 1 of 1

 
Free Windows games


Powered by phpBB © 2001, 2005 phpBB Group and Ask an Expert
Also powered by Darren and the other admin and mods' hard work! ;)