I created a simple test site and everything works fine but when I apply the same code to the actual site I get an external link icons on everything and my url titles are showing up on internal links.
What am I doing wrong?
I not want external link icon on internal or anchor links.
Oooh dear, there’s quite a few things you’ll need to look at here.
To get rules to apply to only external links, you need: a[href^="http:"] { [I][COLOR="DarkSlateGray"]rules go here[/COLOR][/I] }
To get rules to apply to only email links, you need: a[href^="mailto:"] { [I][COLOR="DarkSlateGray"]rules go here[/COLOR][/I] }
I’m not sure what’s going on with <a href="http://quicklinks">Quicklinks</a></li>
unless that’s a link to some kind of intranet service. It’s certainly no good for a regular website, whether it’s supposed to be a link to another site, or an internal link within your own site.
Your use of headings is, um, a bit erratic. The top-level heading should be <h1>, then <h2> for the first level of subheadings, <h3> for the next level down, and so on. You start off with <h6> on something that looks like it isn’t a heading at all, then <h5> for the main heading, then <h1>s for the sub-headings.
A better plan than [color="#cc0000"]<h1><a name="toc_4"></a>Title</h1>[/color] would be [color="green"]<h1 id="toc_4">Title</h1>[/color]. Even better would be to replace toc_4 with a word related to the section title.
Then you appear to have a script after the end of the </html> section, which isn’t allowed (unless you meant that to be a separate file, which would be fine, it just wasn’t clear from the .txt you’ve uploaded if that’s the case).
The Javascript is a separate file, I just included it in the .txt incase you needed to look at it. The Javascript puts the url title You are leaving only on the non quicklinks/quicklinks-qa links.
So in my code for the mailto
a[href^=“mailto:”]
{
display:inline-block;
padding-left:20px;
line-height:18px;
background:transparent url(C:/QuicklinksSynchronized/images/link_icons/email_link.gif) no-repeat 100% 0;
padding: 0 20px 0 0;
}
^ means it only looks for that string at the start of the URL
means it looks for the string anywhere in the URL.
When the string is http: or mailto:, you know it’s going to be at the start, so using ^ means the computer has to do less work, meaning a faster page load and render.
so when I use ^ the external link icons are now puts on the quicklinks/quicklinks-qa link and the external link title are also put on the internal link which I do not want either.
I’ve created a simple test page which I’ve attached.
I can’t follow your logic in that code but you have errors anyway. There should be no space before the colon in the pseudo class and after the “attr” in the content property.
e.g. attr (title)
should be:
attr(title)
and
a[href*=“google”] :hover
should be:
a[href*=“google”]:hover
I think this examples contains all the things you need.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
a {
display:inline-block;
padding-right:14px;
padding: 0 20px 0 0;
}
a[href^="http:"] {
background:yellow url("extlink.gif") no-repeat 100% 0;
padding: 0 20px 0 0
}
a[href^="http:"]:hover:after {
content:" - External - " attr(title);
background:red;
}
/* remove external link from google and title
a[href*="google"]{ background:green;}
a[href*="google"]:hover:after { content: " "; }
*/
a[href^="mailto:"] {
line-height:18px;
background:#ccc url(C:/QuicklinksSynchronized/images/link_icons/email_link.gif) no-repeat 100% 0;
padding: 0 20px 0 0;
}
/*removes external link icon from attributes http://quicklinks/*/
a[href*="quicklinks"] {background:none;}
a[href*="quicklinks"]:hover:after {content: " ";}
</style>
</head>
<body>
<ul>
<li><a title="Yahoo" href="http://www.yahoo.com">Yahoo.com</a> </li>
<li><a title="Google" href="http://www.google.com">Google.com</a> </li>
<li><a title="quicklinks"href="http://quicklinks">Quicklinks</a></li>
<li><a href="http://quicklinks-qa">Quicklinks-QA</a></li>
<li><a href="http://test.com">test</a></li>
<li><a href="#test">Internal Link</a></li>
<li>send an email to <a href="mailto:retailstoresupport@yahoo.com">guesswho@yahoo.com </a></li>
</ul>
</body>
</html>
Thanks for your example. I got it to work However…
I have over 10,000 pages that have need to be updated with external link icons, and url title. Most of the links do not have url titles. That is why I wrote javascript to automatically add the title of you are leaving .
We are using IE 7. so not sure if the background colours are suppose to change to red and green, but I do see the yellow.
I added the titles of the links for testing as I did not want to write a js program to add them to the links. If you want it tested with your js then you would have needed to supply us a working demo.
We are using IE 7. so not sure if the background colours are suppose to change to red and green, but I do see the yellow.
IE7 doesn’t support :after so I assumed you were going for IE8+ only. You’d have to script it for IE7 if you wanted the same functions.
Well, yes. The ‘quicklinks’ links are external, because they’re pointing to a different server. I suppose you could get round that by targeting [noparse]http://www[/noparse] instead of just http, and then just make sure that all external links include the www in them.
and the external link title are also put on the internal link which I do not want either.
Why do you need a title on the link anyway? In almost all cases, the link text should be sufficient without needing a tooltip that a lot of people won’t see or read.
Any hovered links that start with http will have the word “- External -” added after the content in that element and then will also be followed by the text in the title attribute of that element.
Is the background colour showing up for you? If so then it must be a path issue - try an absolute path to the image to make sure.
Do you have a version live that we can debug? If not throw up a quick example somewhere as it will be easier for us to spot live.
Also test in Firefox as well to see whether its a specific IE7 bug and maybe you have a corrupt image in cache or maybe some other IE specific bug triggered…
I’ve tried changing the path. with http:// and c:/
Our pages are posted to quicklinks-qa as development then they are posted to our production site quicklinks. So we can’t use the absolute path, but I’ve tried it anyways and it doesn work either.
We are not allowed to use Firefox which is another stupid thing here lol
I’ve attach css file but it won’t let me attach the html as it is already in a previous thread. test…txt
Just run that page in your browser while online and you will see that the code is working. You must have the wrong path to the image or the image isn’t where you think it is.
So I copied your complete code and saved it as a new file and it works fine, however when I copy your code for the extlinks into my document it doesnt work.
I have compared my code to your code in examdiffpro and it matches exactly, but yet my code document doesn’t work with links to my graphics.
So I created a new simplier test page. it works fine with the same code and my links.
So when your code and my code are exactly the same, why does mine not work?