Open Under Function

Open under

by Alvin Olavarrieta

HTML

<a class="open" href="demo.html" target="_blank" data-href="demo2.html">More Info</a>

JavaScript

// Open under function
$('.open').each(function() {
  $(this).click(function(event) {
    event.preventDefault();
    event.stopPropagation();
    window.open(this.href, '_blank');
    window.location = $(this).data('href');
    window.focus();
  });
});