Skip to content

Commit

Permalink
Fix external links in new tab (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Jul 4, 2018
1 parent 9fdd49a commit c425b73
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/javadoc/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ document.addEventListener('DOMContentLoaded', function () {
var anchors = document.getElementsByTagName('a');
var length = anchors.length;
for (var i = 0; i < length; i++) {
if (anchors[i].href.indexOf('http://') === 0 || anchors[i].href.indexOf('https://') === 0) {
anchors[i].target = '_blank';
if (location.protocol === 'http:' || location.protocol === 'https:') {
if (anchors[i].href.indexOf(location.origin) !== 0) {
anchors[i].target = '_blank';
}
} else {
if (anchors[i].href.indexOf('file:') !== 0) {
anchors[i].target = '_blank';
}
}
}
}, false);

0 comments on commit c425b73

Please sign in to comment.