//add rel=noopener to any target=_blank links (function(){ //minimum requirements... if a browser is old enough not to //handle these, window.opener is the least of its worries if( !('querySelector' in document && 'querySelectorAll' in document) || !('addEventListener' in window) || !('opener' in window) ) return; //detect potentially dangerous targets var badTarget = function(target){ return (!target || ['_self', '_top', '_parent'].indexOf(target) === -1); }; //detect potentially dangerous destinations var badDestination = function(href){ return (href && !/^\#/.test(href)); }; //add/update rel=noopener var updateLinks = function(){ var links = document.querySelectorAll('a[target=_blank]'); if(links.length){ for(i=0; i