does anyone know of a script that automatically converts inline text links to the actual URL when the documented is printed?
thank you :-)
| SitePoint Sponsor |

does anyone know of a script that automatically converts inline text links to the actual URL when the documented is printed?
thank you :-)
CSS does the trick for non-IE browsers.
You can try this bit of javascript for IE, but I'm not sure it will work:Code:a:after { content: attr(href); }
Assuming that function works, you'd have to create another function for IE's onafterprint event handler to restore the links back to their original states (without the href in the link text).Code://caution: code is untested onbeforeprint = function () { var links = document.getElementsByTagName("a"); var i = 0, thislink; while (thislink = links[i++]) { var tn = document.createTextNode(thislink.getAttribute("href")); thislink.appendChild(tn); } }

thanks vinnie, but i'm afraid that is a bit over my head. and wouldn't that display them onscreen as well?
as a guess, though, could i do it as onprint rather than onbeforeprint so they would dipslay as normal links onscreen and i would not have to have the afterprint code?
For the CSS part, not if you put it in a print-media stylesheet. Example:Originally Posted by mtouchette
This will show whatever the HREF attribute is for the link on the printed page but keep it offscreen.HTML Code:<style type="text/css" media="print"> <!-- a:after { content: attr(href); } --> </style>
If you set them onprint, you still have to remove them after printing. I prefer using the onbeforeprint event, but feel free to try onprint.as a guess, though, could i do it as onprint rather than onbeforeprint so they would dipslay as normal links onscreen and i would not have to have the afterprint code?
Bookmarks