A Simple JQuery plugin to convert urls found in strings or in an elements html into clickable links.
On an element
$(selector).linkit(options)
linkit can aslo be used on a string like so:
$.linkit(string, options)
Linkit also supports overriding its default options by passing a options object as a parameter. The default values are listed below
$(selector).linkit({
target: null, //Defaults to null, used to set the target attribute on a link eg. "_blank"
protocolRegex: /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,
wwwRegex: /(^|[^\/])(www\.[\S]+(\b|$))/gim,
protocolTemplate: "<a href='$1'>$1</a>",
wwwTemplate: '$1<a href="http://$2">$2</a>'
})
Example
To set all links to have a target of _blank use the following options.
$(selector).linkit({
target: "_blank"
})