Press "Enter" to skip to content

jQuery Plugin That Invisibly Adds An External Window | Externalize

Externalize is a jQuery plugin that subtly adds an external window creation to a set of links that dynamically sets the name, relation, target, and title attributes to links within the document.

A typical use case for this plug-in is to open the external link in a new window, with the rel = “external” attribute.

find urls in text make links javascript, which selector would select only internal links within the current page, jquery check if link is external, javascript detect external link, add target blank to url

How to make use of it:

Installation:

# Yarn
yarn add jquery-externalize

# NPM
$ npm install jquery-externalize

1. Load each jQuery library and the Externalize plugin’s script on the finish of the doc.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.externalize.js"></script>

2. Initialize the plugin on the links and completed it.

$('.ref a').externalize();
<a href="#">Externalize Links</a>
<a href="#" rel="external" title="Opens in a new window" target="external">Externalize Links</a>

3. Default configuration choices.

$('.ref a').externalize({

  // (string) name of the external window
  name:     "_blank", 

  // (bool) use the "target" HTML attribute to support Firefox tab handling and Safari status bar info
  target:   true, 

  // (string) apply CSS classes to an external link
  classes:  "", 

  // (string) apply a relationship to an external link
  relation: "external", 

  // (string) text added as or appended to the "title" attribute to inform the user about an upcoming new window
  title:    "Opens in a new window" 

});

jQuery Plugin To Set Rel And Target Attributes For Links, jquery open external links in new tab, which value of the target attribute makes the link open in a new tab or a new window, jquery external link


See Demo And Download

Official Website(Dreamseer): Click Here

This superior jQuery/javascript plugin is developed by Dreamseer. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *