Open links in a new tab using jQuery

Javascript Dec 09, 2014

The most common way to open links in a new tab is to middle click the link in the web browser or right-click. To open a link in a new tab by default you need to add target="_blank" to the hyperlinks, but this would get annoying over time if you have to add this to every link in your source. You can add this simple jQuery snippet to your source to open every external link in a new tab of the web browser. If you don’t already have jQuery need a local copy of it or use Google’s hosted library CDN for jQuery.

How to create a sketch app in JavaScript using P5.JS
I have been learning P5.JS [https://p5js.org/] for a while now and though it would be nice to share the process and progress in form of a tutorial, which will motivate me to continue learning and give others access to it. We will learn how to create a sketch app [http://darryl.netlify.com/app/p5/sketch-basic/…
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>`

You need to load jQuery before this script loads or else this script won’t work.

$(document).ready(function(){
  $('a').each(function() {
    var a = new RegExp('/' + window.location.host + '/');
    if(!a.test(this.href)) {
      $(this).click(function(event) {
        event.preventDefault();
        event.stopPropagation();
        window.open(this.href, '_blank');
      });
    }
  });
});

Emmet for Atom
Emmet is a plugin available for popular text editors that let you write HTML abbreviations without having to directly write HTML tags, instead use Emmet’s shortcuts.It reduces the amount of HTML the user has to write and increases efficiency and saves precious time. A simple example. article&gt;heade…

If you like this content, please consider buying me a coffee.

Buy me a coffeeBuy me a coffee

You will get access to contributer exclusive resources and content.

Thank you!



Darryl Dias

I am a student, artist, and author currently living in Florida. My interests range from technology to arts. I am also interested in programming, writing

Analytics by GoSquared