How to Enable the Print Screen Function Using JavaScript
The document object model in JavaScript provides the functionality to make the action of printing a Web page with a limited amount of coding. Make this small amount of coding available to your website users so they will take advantage of printing their screen, generating better results for your site.
Instructions
-
-
1
Open the text editor and insert the following lines of HTML code:
<html>
<body>
Sample text to print -
2
Insert the following line to create the link to print the Web page using JavaScript:
<a href="javascript:window.print()">Print this page</a> -
-
3
Complete the Web page by inserting the following lines of code to close the HTML tags opened in the code from Step 1:
</body>
</html> -
4
Save this file to the "C" drive with the name "test.html."
-
5
Open your Web browser and type "file:///c:/test.html" in the URL bar and press "Enter." The Web page you created will appear in the browser. Click on the link "Print this page" to print the Web page.
-
1
References
- Photo Credit internet image by Soja Andrzej from Fotolia.com