AbsorbingChaos / unmuteable-com

UN ✕ MUTE ✕ ABLE
https://unmuteable.com
0 stars 0 forks source link

Open external links in new window #33

Closed whoabuddy closed 4 years ago

whoabuddy commented 4 years ago

Due to markdown limitation on link targets, add javascript to append target="_blank" to any external links.

Example code from StackOverflow:

var links = document.links;

for (var i = 0, linksLength = links.length; i < linksLength; i++) {
   if (links[i].hostname != window.location.hostname) {
       links[i].target = '_blank';
   } 
}
whoabuddy commented 4 years ago

Simpler approach might be to use Markdown Render Hooks which would happen before page load.