Automating the opening of external links in a new tab on your Webflow site can enhance user experience without requiring manual adjustments per link.
target="_blank" to all external links while keeping internal links opening in the current tab. Insert the following line of script in the Before </body> tag section:document.querySelectorAll('a[href^="http"]').forEach((link) => { if (!link.href.includes(window.location.hostname)) { link.setAttribute('target', '_blank'); } });target="_blank" to qualifying links.
In summary, by adding a small JavaScript snippet in the Custom Code section of your Webflow project, you can automate the process, ensuring all external links open in a new tab while keeping internal links unaffected. This approach streamlines link management without requiring manual adjustments for each link.