HTML and CSS Reference
In-Depth Information
Bill Beckelman has written a post about this on his blog at
text-when-printing-in-ie6-and-ie7/ . IE supports its own proprietary
onbeforeprint and onafterprint events that can be used to our advant-
age. Based on Bill Beckelman's work, we can write our own simple jQuery code
to print link URLs in IE6 and IE7.
First, we check if window.onbeforeprint exists, because this would indicate this
code is being executed on one of the IE browsers. We also want to verify if this
browser supports generated content or not, as we only need to use this code when
it is not supported. The following code snippet checks for the presence of the win-
dow.onbeforeprint event:
if (Modernizr.generatedcontent == false
&&window.onbeforeprint !== undefined) {
Then, we set functions to execute when either onbeforeprint or onafterprint
occurs, as shown in the following code:
window.onbeforeprint = printLinkURLs;
window.onafterprint = hideLinkURLs;
Then, we write the following functions:
functionprintLinkURLs() {
$("a[href]").each(function() {
$this = $(this);
$"originalText", $this.text());
$this.append(" (" + $this.attr("href") +
Search WWH ::

Custom Search