You are viewing a plain-jane printable version of http://CoverYourASP.com/PrinterFriendly.asp.
See how this was done

 

Since I added the "Printer-friendly page" option on the left of the page I've noticed quite a few failed searches for a description of how it works. So here it is!

It's very simple. The link on the left of the page is made up from the following code in utils/Header.asp, designed to call the current page with "plain" added to the URL.

// get name of current page
var sPage = '' + Request.ServerVariables ( "SCRIPT_NAME" );

// get QueryString if there is one
var sQuery = '' + Request.QueryString ( );

if ( sQuery != '' )
   sQuery += '&';

Response.Write ( '<a href="' + sPage + '?' + sQuery + 'plain">Printer-friendly page</a>' );

Since the URL of the page may already have some parameters in the QueryString (the part following a ? in the URL), I either have to add ?plain or &plain.;

The "plain" in the URL is detected in utils/Init.asp, and the bPlainJane variable set when it is found:

// if we're passed in 'plain' in the querystring we'll make
// the page as plain as possible for printing
bPlainJane = Request.QueryString ( 'plain' ).Count;

Note that although I use the b prefix to imply the variable is a boolean, it really is the number of "plain" parameters in the URL. I just use it as a boolean expression.

Then it's a simple matter of testing bPlainJane where there is content that you want to add or remove for the plain version of the page. As an example, a new header is shown at the top of the printer-friendly page with this code in utils/Header.asp:

// should we make a plain page for printing?
if ( bPlainJane )
{
   // table containing rest of body
   Response.Write ( '<table bgcolor="#ffffff" width="600" border="0" cellpadding="0" cellspacing="0">' );
   Response.Write ( '<tr><td align="center"><h5>You are viewing a plain-jane printable version</a></td></tr><tr>' );
}
else
{
   // display left navigation bar

In fact this code not only displays a new header, but it also uses a narrower fixed-width table to contain the page, and stops the left navigation bar displaying. In a similar manner the right side of the page is removed.