Developer forum

Forum » Dynamicweb 10 » Open external links in new tab

Open external links in new tab

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Is this option from the website settings connected to the Navigation or other parts of the Swift 2 in any way?

Thank you,
Adrian


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

It is a Swift 2 setting. We deleted the feature from code - but forgot to remove the setting.

So now we had to re-introduce it: https://doc.dynamicweb.dev/documentation/fundamentals/dw10release/releasenotes/workiteminfo.html?workitemid=26181

We basically just do it JS:
function secureExternalLinks() {
    document.querySelectorAll('a[href*="://"]').forEach(link => {
        if (!link.hasAttribute('target')) link.target = '_blank';
        const rel = link.getAttribute('rel') || '';
        link.setAttribute('rel', `${rel} noopener noreferrer`.trim());
    });
}

 

 

 

You must be logged in to post in the forum