1.0.4 • Published 5 years ago
@sayhellogmbh/maybe-set-link-target v1.0.4
Maybe set link target
jQuery script which parses all specified link tags, analyses the URLs. If the URL is an external link and matches the following conditions, then the target
attribute is set to _blank
.
- Does not already have an explicit
target
attribute - Is not an anchor link.
- Is not in the same domain as the current page
- Is not in the
www
subdomain of the current page - Not a
javascript
link - Not a
mailto:
link - Does not have the CSS class
anchor
- Does not have the CSS class
fancybox
- Does not have the CSS class
toggle
Usage
$("a").maybeSetLinkTarget();
Changelog
1.0.4 2020-03-11
- Fix jQuery error
1.0.3 2020-03-11
- Add rel=noopener to links set with blank targets
1.0.2 2020-03-11
- Add rel=noopener to links set with blank targets
1.0.1 2019-02-15
- Fix null matching in URL parsing
1.0.0 2019-01-18
- Initial NPM version