Reputation: 1211
Simple question: How do you add target=“_blank” to the returned link in the following function?
String.prototype.parseHashtag = function() {
return this.replace(/[#]+[A-Za-z0-9-_]+/g, function(t) {
var tag = t.replace("#","%23")
return t.link("http://search.twitter.com/search?q="+tag);
});
It is printed like this:
$("#twitterFeed span").html(data[twitterNumber].text.replace(urlRegexp, "<a target=_blank href='$1'>$1</a>").parseHashtag().parseUsername());
Upvotes: 1
Views: 1126
Reputation: 173662
You probably have to do it yourself:
return t.link("http://search.twitter.com/search?q="+tag)
.replace(/^<a/, '$& target="_blank"');
Upvotes: 2