Hi,
I've used an excellent way to make target="_blank" links that still
validate while using HTML 4.01 Transitional doctypes in the past.
I learned the trick from : http://www.sitepoint.com/article/1041
Basically, instead of typing :
<a href="yourlink. html" target="_blank" alt="">The link</a>
You type :
<a href="yourlink. html" class="external " alt="">The link</a>
And it's the same due to this little piece of javascript :
/* Evite de mettre des target="_blank" */
function externalLinks() {
if (!document.getE lementsByTagNam e) return;
var anchors = document.getEle mentsByTagName( "a");
for (var i=0; i<anchors.lengt h; i++) {
var anchor = anchors[i];
if (anchor.getAttr ibute("href") &&
anchor.getAttri bute("class") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
Now, eventhough this perfectly works, I wish I could do a little
something more (with your help).
What I would like to archieve would be the following :
When typing :
<a href="yourlink. html" class="external " alt="">The link</a>
I would like to obtain :
<a href="yourlink. html" class="external " alt="">The link</a> (<a
href="yourlink. html" class="external 2" alt="">new window</a>)
So what I would like is the ability to :
1°) Add (<a href="yourlink. html" class="external 2" alt="">new
window</a>) after my original link
2°) indicate by this mean that the link could be followed either on the
same page or another one.
3°) have class="external " that opens nothing and class="external 2" that
opens a new window automaticaly.
What I don't know is :
1°) Is it feasible using only javascript ?
2°) Is it possible only by specifiing class="external " in the original
link (and having javascript doing the subsequent coding) ?
3°) Is someone able to come up with a solution (because I truly can't)
Hope I'll get some expert coders attention ;)
Greetings.
R.