Skip to content

Instantly share code, notes, and snippets.

@kemayo
Last active December 1, 2017 17:19
Show Gist options
  • Save kemayo/fc60e10d343fa03a7c909065deb46e02 to your computer and use it in GitHub Desktop.
Save kemayo/fc60e10d343fa03a7c909065deb46e02 to your computer and use it in GitHub Desktop.
( function ( $ ) {
$.fn.openInNewWindow = function () {
var rel;
if ( this.tagName.toLowerCase() === 'a' ) {
this.setAttribute( 'target', '_blank' );
rel = this.getAttribute( 'rel' );
this.setAttribute( 'rel', rel ? ( rel + ' noopener' ) : 'noopener' );
}
}
)( jQuery )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment