Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including external-link with all npm packages installed. Try it out:

var externalLink = require("external-link")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

external-link v2.0.0

Check whether a link dom node links to an 'external' website.

External Link

npm version Build Status Coverage Status MIT Licensed

A simple function that tells you whether a link DOM node is 'external'.

A link is external if it:

  • has the attribute rel="external"
  • has the attribute target and the value is not _self
  • is an absolute link
  • is a telephone link
  • is a mailto link

To use

var external = require('external-link');
var link = document.querySelector('a');



2.0.0 - changed handling of target so that any value other than _self will make it external

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free