Skip to content

Instantly share code, notes, and snippets.

@leedo
Created August 30, 2011 21:58
Show Gist options
  • Select an option

  • Save leedo/1182198 to your computer and use it in GitHub Desktop.

Select an option

Save leedo/1182198 to your computer and use it in GitHub Desktop.
make links clickable
makeLinksClickable: function(elem) {
var children = elem.childNodes;
var length = children.length;
for (var i=0; i < length; i++) {
var node = children[i];
if (node.nodeName == "#text" && node.nodeValue.match(Alice.RE.url)) {
var span = new Element("SPAN");
span.innerHTML = node.nodeValue.replace(
Alice.RE.url, '<a href="$1" target="_blank" rel="noreferrer">$1</a>');
node.parentNode.replaceChild(span, node);
}
else {
Alice.makeLinksClickable(node);
}
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment