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:
- 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();
}
- Open a new window (command-N) or a new tab (command-T) in Safari.
- Paste the text in the address field at the top of the window. Even if there are several lines, it will be OK.
- Drag and drop the URL symbol (the blue globe on the left of the address field) to the bookmarks bar.
- 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.
- Click once to print the page.
- 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:
- The two-click procedure is due to asynchronous print processing. Too bad!
- The header is only printed on the first page. To define a global header implies using a specific CSS stylesheet.
- I tried very hard to achieve the same feature using the default stylesheet of Safari, but could not find the way to acces URL from the CSS code.
- The "print button" tip is borrowed from someone on the net. It was a standard print using javascript:window.print().
[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