Decad / linkit

JQuery plugin to convert urls into links.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linkit

A Simple JQuery plugin to convert urls found in strings or in an elements html into clickable links.

Usage

On an element

$(selector).linkit(options)

linkit can aslo be used on a string like so:

$.linkit(string, options)

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"
})

About

JQuery plugin to convert urls into links.


Languages

Language:JavaScript 100.0%