12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Oct 6, 2019

How to automatically open external links in a new window/tab

Sridhar Katakam

This tutorial shows how links to external sites can be set to open automatically in a new window/tab when using Oxygen.

Here’s How

Edit the Main Catch All Template.

Add a Code Block at the very end below all other top-level Sections/elements.


	// echo "hello world!";


(function($) {

	.filter('[href^="http"], [href^="//"]')
	.not('[href*="' + window.location.host + '"]')
		rel: 'noreferrer noopener',
		target: '_blank'


Opening all Links in a Section in new window/tab

If you wish to open all the links inside a particular element, say a Section but not all external links throughout the site, use the following JS instead inside the particular Template/Page:

jQuery('#section-178-2 a').attr({
	target: "_blank",
	rel: "noreferrer noopener"

Replace section-178-2 with the ID of the parent container having the links.