OK, so maybe I'm a little too bored/geeky for my own
good...
The following code fixes something that's been bugging me for
a while.
Everyone but IE seems to be able to use the "content"
attribute in CSS.
This bit of _javascript_ basically fixes that. Read the comments
in the code and have a play with it.
:::::: CODE ::::::
/*// Print our HREFs on Links for Print
StyleSheet
There's a cool bit of CSS that shows a link's URL after
it:
a:after { content:" [" attr(href) "] " }
Great for Print StyleSheets, but unfortunately MSIE doesn't
implement this.
So here's some code that replicates that functionality for all browsers :o) On the plus side, it also lets you style the URL anyway you want, instead of having it relegated to part of the link itself. *///
function showHREF() {
if (document.getElementsByTagName) { > whichLink = onlyContentLinks.getElementsByTagName("a"); for (var i=0; i<whichLink.length; 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.>
Richard :o)
|