|
JavaScript Home
JavaScript Tutorial Home Basic JavaScriptIntroductionHow to Enable JavaScript JavaScript Syntax External JavaScript File JavaScript Operators JavaScript Variables JavaScript Functions JavaScript Events JavaScript If Statements JavaScript Switch Statements JavaScript While Loop JavaScript For Loop JavaScript Try Catch JavaScript Escape Characters JavaScript Void(0) Advanced JavaScriptJavaScript CookiesJavaScript Date and Time JavaScript Arrays Two Dimensional Arrays JavaScript Summary JavaScript ReferenceJavaScript Reserved WordsJavaScript Event Handlers JavaScript Date and Time Functions JavaScript Code LibraryJavaScript Dropdown MenuJavaScript Print JavaScript Alert Box JavaScript Status Bar Messages Image Rollovers Popup Windows JavaScript Redirect Timed JavaScript Redirect JavaScript Refresh Page Timed JavaScript Redirect Got a MySpace Page?Get "www.yourname.com" for your MySpace page. Learn how >>. |
JavaScript PrintYou can use JavaScript to automatically open print dialogue box so that users can print the page. Although most users know they can do something like File > Print, a "Print this page" option can be nice. Also, this code can be triggered automatically upon loading a printer friendly version. To create a "Print this page":The following code creates a hyperlink and uses the Javascript print function to print the current page: <a href="JavaScript:window.print();">Print this page</a>
The above code results in the following: Print this pageTo automatically open the print dialogue box:You can call the JavaScript print function upon loading a Printer friendly version. This will automatically open the print dialogue box for the user.
So, your body tag should look something like this: <body onload="printpage()">Enjoy this website?
Oh, and thank you for supporting Quackit! |
FREE Hosting!With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.PLUS you get:
Featured Template:
(Build your websites in minutes!) |