MediaWiki:Common.js: Difference between revisions

No edit summary
Tag: Manual revert
No edit summary
Line 9: Line 9:
     }
     }
   }  
   }  
}
// Force links to open in new tab in embed mode
if (document.body.classList.contains('vc-embed-mode')) {
  document.addEventListener('DOMContentLoaded', function () {
    const links = document.querySelectorAll('a[href]');
   
    links.forEach(link => {
      const href = link.getAttribute('href');
      // Skip anchors and empty links
      if (!href || href.startsWith('#')) return;
      // Make all links open in new tab
      link.setAttribute('target', '_blank');
      link.setAttribute('rel', 'noopener noreferrer');
    });
  });
}
}