Alternate document for printing
Printing a page online usually means printing more than what you actually want. Webpages are quite fancy nowadays, with ad banners on top, navigational links on the left, and so on. That's fine when you're viewing the page online, but when you're printing the page, you only want to print out the "actual content", and nothing else from the page! Many sites nowadays understand this, and provide an alternate "print" version of the document that surfers can go to and print out. Well, there's actually a much more elegant and seamless way of accomplishing the same thing, and that is by using the <link> tag. IE 4+ supports a version of the <link> tag that allows you to specify to thr printer which file it should print when the user selects print. In other words, the job of locating the alternate print version of the document to print out is left to the printer, instead of the surfer. Take a look at the below example, and it will all be clear.
Demo: Let's say you're interested in only printing out the content in gray below from this page. As the webmaster, I could have helped you out by creating another HTML document with only the below content, and telling you to go there and print that document instead. However, I'm not going to do that. Instead, I've prepared a Word document called printversion.doc, and by adding the following:
<link rel=alternate media=print href="printversion.doc">
to the <head> section of this page, informed the printer to directly proceed to printversion.doc and print it when you select "print" on this page. In other words, the printer will print out printversion.doc instead when you choose "print" on printstyle.htm. To see this in action, try printing this page now (you'll need IE 4 or above)!
The following article discusses what DHTML is, and also the differences in implementation of DHTML between Netscape Communicator and MS Internet Explorer 4.What is DHTML? What's the difference between DHTML in
Communicator, and in Internet Explorer 4.0? In Communicator:
In Internet Explorer 4:
What's the difference between JavaScript1.2
and DHTML? document.layers is a JavaScript 1.2 coding that accesses the layer object of NS 4. In IE 4, web developers can use scripting languages other than JavaScript 1.2 to access its DHTML features, such as VBScript, JScript etc. NS 4 does not allow that kind of liberty. What is the relationship between CSS (Cascading Style Sheets) and DHTML? CSS is a styling technology that allows web developers the liberty to apply style and formatting to a document through a centralized location. In Netscape 4, that is all that CSS does, but IE 4 also utilizes CSS (namely, the id attribute of CSS) to allow web developers easy access to various elements in a document. |
Directions:
Simply copy the below into the <head> section of your web page. Change printversion.doc to the file intended to be used for printing. The file can be of virtually any format (pdf, Word etc). When the user selects "Print", the printer will look for this file and print it instead of the current page. Netscape will simply ignore this tag, and print out the original page.
Pretty neat, uh? At least we thought it was :-)