Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change IE page setup and font size before printing

Status
Not open for further replies.

laurent42

Programmer
Aug 7, 2001
13
US
I would like to add a boutton and some Javascript code to an HTML page so that by pressing the button, the page setup is changed to "landscape" and the font size is changed to "smallest" and the print window opens.

Is it possible to include some parameters to window.print() or do I have to use something else than some Javascript code?

Thansk a lot.
 
You cannot control printer choices through the browser with Javascript. To control font sizes strictly, you have to use <div> and <style> statements, and not <font>, which is controlled by user choices in the browser. In IE, you can click on View, then Text Size to make text larger or smaller that is defined on a web page with <font> tags.

As well, each printer make and model prints web pages a bit differently, and the users screen resolution affects that, as well. There's no way you can have that kind of control outside of sitting in front of the user's computer.
 
</html>
...
<script languague=&quot;javascript&quot;>
<!--
function advprint {
// will work only on IE4+
document.wanted.style.color.value = desiredcolor;
document.wanted.style.font-size.value = desiredsize;
document.wanted.style.font-family.value = desiredface;
// etc
// read on print();
}
-->
</script>
</head>
...
<p id=&quot;wanted&quot;>yourtext</p>
<input type=&quot;button&quot; onclick=&quot;advprint()&quot; value=&quot;Print Me&quot;>
...
</html>
hope i helped u a little
Regards someone knowledge ends were
someone else knowledge starts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top