2017-08-05 16:52:37 +00:00
|
|
|
let links = [];
|
2017-08-05 16:40:57 +00:00
|
|
|
|
2017-08-05 16:52:37 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
links = document.querySelectorAll('a:not([target])');
|
|
|
|
});
|
2017-08-05 16:40:57 +00:00
|
|
|
|
|
|
|
function setOpenInNewTab(bool) {
|
|
|
|
if (bool === false) {
|
2017-08-05 16:52:37 +00:00
|
|
|
links.forEach(l => {
|
|
|
|
l.removeAttribute('target');
|
|
|
|
l.removeAttribute('rel');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
links.forEach(l => {
|
|
|
|
l.setAttribute('target', '_blank');
|
|
|
|
l.setAttribute('rel', 'noopener noreferrer');
|
|
|
|
});
|
2017-08-05 16:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
setOpenInNewTab
|
2017-08-05 16:52:37 +00:00
|
|
|
};
|