jQuery Plugin To Detect Broken/External/Anchor Links - link-checker.js

File Size: 4.86 KB
Views Total: 2099
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Detect Broken/External/Anchor Links - link-checker.js

link-checker.js is a simple yet really useful jQuery plugin that automatically detects broken / internal / external / anchor links within the document and then adds corresponding CSS classes and rel & target attributes to them based on the URLs.

See also:

How to use it:

1. To get started, include the jQuery link-checker.js script after you've loaded jQuery library as this:

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="link-checker.js"></script>

2. Initialize the plugin and we're ready to go.

$('a').linkChecker();

3. Style the links based on their current status:

.internal-link { ... }

.external-link { ... }

.anchor-link { ... }

.broken-link { ... }

4. By default, the plugin will automatically adds the rel='nofollow' and target='_blank' attributes to your external links. You can disable them in the JavaScript as this:

$('a').linkChecker({
  externalLinkNoFollow : true,
  externalLinkBlank : true
});

5. More configuration options.

$('a').linkChecker({
  hostname : new RegExp(location.host),
  animateAnchorLinks : true // for scroll to
});

This awesome jQuery plugin is developed by weLaunch-io. For more Advanced Usages, please check the demo page or visit the official website.