Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active August 15, 2020 07:23
Show Gist options
  • Save wpscholar/4637176 to your computer and use it in GitHub Desktop.
Save wpscholar/4637176 to your computer and use it in GitHub Desktop.
Open all external links in a new window
@YupItsZac
Copy link

Nice gist, @wpscholar. I wrote a jQuery plugin for this that includes several options for customizing the way external links and files are handled.

https://github.com/YupItsZac/jQuery.exLink

@wpscholar
Copy link
Author

Updated gist to support "noopener noreferrer". See https://medium.com/@jitbit/target-blank-the-most-underestimated-vulnerability-ever-96e328301f4c for details.

@mpiprojects
Copy link

mpiprojects commented Jan 2, 2018

Assuming I can add "nofollow" to the rel attribute as well. Could you give me an example script on how to add an exception, for when the A tag has class=trusted? Where only the target attribute is set and the rel attribute is left empty. Many thanks and happy new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment