DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Use JQuery To Make All External Links Open In A New Window/tab

  • submit to reddit
        This Javascript snippet will make it so that all external links will open in a new window or tab.

$(document).ready(function() {
      if(this.href.indexOf(location.hostname) == -1) {
            target: "_blank",
            title: "Opens in a new window"