/** * @author Michael Pih (mpih@getactive.com) * @version $Id: printer-friendly.js,v 1.2 2009/08/13 05:53:20 mpih Exp $ **/ /** * Redirects or pops open a new window to the printer-friendly mode of the page. * The original request URI and query string are preserved. * * Example usages: * Printable View * or * Printable View * * @param target A target window, defaults to 'print' */ function doPrinterFriendly(target) { var requestURL = window.location.href.split("#")[0].split("?")[0]; var queryString = window.location.search.substring(1); var bookmark = window.location.hash.substring(1); var pfQueryString = ""; if (queryString != "") { var vars = queryString.split("&"); for (var i=0;i 0) { pfQueryString += "&"; } pfQueryString += pair[0] + "=" + pair[1]; } } pfQueryString += "&"; } // Redirect to the printer-friendly mode of the page. pfQueryString += "print=t"; var pfRequestURL = requestURL + "?" + pfQueryString; if (bookmark != "") { pfRequestURL += "#" + bookmark; } if (target == null) { target = 'print'; } window.open(pfRequestURL, target); return; }