Don’t really know where to ask this question, but I’ll try here.
I have a site which has a Links-page and this page is somewhat filled with links. And also, I have about 17 more sites that uses the same setup, basically.
I would like to have target="_blank" added to all the links in just that page, since using the editor to set all the links to open up in a new window would take ages to do.
Now this would’ve worked fine if the Link Attributes setting actually worked.
It seems it hasn’t worked since 0.9.5, well, atleast it seems that wat by the info I found in the forum.
I couldn’t find it in JIRA either, but that could be do to my poor searching skills in JIRA.
Is link attributes working or not and if it does, what is the magical code for it?
Cheers
Amrit
I make use of this:
http://scottydelicious.com/blog/2008/06/12/xhtml-new-window-links
Then I have my links as weblink-documents in modx manager and give them the rel="external" in either link attribute field or in the template chunks or inside of the snippets I use so it adds automatically.
There are bunch of snippets, plugins and stuff you can use...
http://www.modxcms.com/Autolink-507.html
The link-attribute field is NOT made to automatically add that field to all links in a doc.
There. Now I got it working with jQuery.
Just had to make shure it didn’t clash with my slimbox and mootools.
Thanks for pointing me in the right direction.
Cheers
Amrit
external.js
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;
Most excellent. Thank you.