"If You Can Dream It, We Can Build It"
Let us help your dream come true in web and multimedia design and development to open the doors to the digital world.
Use JavaScrip to Print
JavaScript can be used to print the content of your webpage or part of your webpage. However, to control the print layout easiest and efficient way is to use separate CSS. Step by step this tutorial will show how to use JavaScript and CSS to make printer friendly web page.
JavaScript print function window.print()
The JavaScript function window.print() is the basic print method to be used to print your web page. This will print the content of the webpage as you see it on screen. In another words this function do the same job as browser print (CTR + P) does. As you do not have control over the JavaScript you just have to design a new printer friendly page.
How to Use
<form>
<input type= “button” value=”Print” onClick=”window.print()”>
</form>
HINT: How to make a printer friendly page.
If you are using HTML page width should not be more than 595 pix. That is the printer friendly width for standard A4 size paper.
<table width=”595”>
<tr><td>
<h1>Print me </h1>
Content will be placed here to print. This can contain text images and it will print as it is.
</td></tr>
</table>
If you are using CSS for presentaion create a sperate CSS and define the page width to 595.
Next: Print Dynamic Pages Using JavaScripts
As I get time I will explain how to use JavaScript to print selected area of your webpage.
Please use any of this content to improve your web and if you have any questions please feel free to contact microsector.net
|