Print a header with the page address (URL) in Safari

Feb 09, '05 08:53:00AM

Contributed by: Max_B

Default printing in Safari does not add a header with the page address (URL), as do other browsers. This is OK for me, most of the time, but sometimes not. Here is a tip to fill the gap:

  1. Select and copy the following code:
    javascript: 
    if (document.body.firstChild.id == 'print_URL_header') {
    document.body.removeChild(document.body.firstChild);
    } else {
    entete = document.createElement('pre');
    entete.setAttribute('id','print_URL_header');
    entete.appendChild(document.createTextNode(document.URL));
    document.body.insertBefore(entete, document.body.firstChild, null);
    window.print();
    }
  2. Open a new window (command-N) or a new tab (command-T) in Safari.
  3. Paste the text in the address field at the top of the window. Even if there are several lines, it will be OK.
  4. Drag and drop the URL symbol (the blue globe on the left of the address field) to the bookmarks bar.
  5. Give this bookmark a name in the pop-up dialog (e.g. Print URL Header). You now have a new "button" for this specific function.
  6. Click once to print the page.
  7. Click a second time to clean up the added header from the displayed page.
You can move this bookmark as you like, as with any bookmark.

Remarks: [robg adds: This hint originally appeared on Max_B's own tip page. I have modified it slightly (changed formatting and a word or two). Thanks for sharing, Max!]

Comments (15)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050205110351171