Avec les CSS et un peu de JavaScript il est possible d’imprimer aussi sur papier les liens présents sur une page à l’aide du script ci-dessous (Source: liste de discussion de Web Standards Group):
Dans le CSS destiné à l’impression:
a:after { content:" [" attr(href) "] " }
Dans la page HTML:
function showHREF() {
if (document.getElementsByTagName) {
onlyContentLinks = document.getElementById("content");
whichLink = onlyContentLinks.getElementsByTagName("a");
for (var i=0; i useLink = whichLink[i];
showLink = useLink.getAttribute("href")
// This is for FireFox to get the whole URL if it's a link to a page within your own site
if (useLink.getAttribute("rel") != "external") {
// NOTE: this assume you are using rel="external" for external links
// You can swap this with...
// if (useLink.getAttribute("target") != "_blank") {
// Because MSIE will show the full path we have to crop it
checkShow = showLink.lastIndexOf("/");
showLink = showLink.substring(checkShow+1,showLink.length);
// Because FireFox doesn't, we have to add it
lastSlash = document.location.href.lastIndexOf("/");
directory = document.location.href.substring(0,lastSlash);
// Our funky complete URL for internal pages
showLink = directory + '/' + showLink;
}
newSpan = document.createElement("span");
showTitle = document.createTextNode(' [' + showLink + ']');
newSpan.appendChild(showTitle);
useLink.parentNode.insertBefore(newSpan,useLink.nextSibling);
// Don't forget to put .printLink in both
// your screen and print stylesheets
newSpan.className='printLink';
}
}
}
window.onload = showHREF();
none