Pop Under

by Alvin Olavarrieta

HTML

<!DOCTYPE html>
<html lang="en">

  <head>
    <title>Open Under</title>
  </head>

  <body>

    <!-- <button id="openUnder" class="form-control btn btn-info">Hello, Click me for open under</button>
    <a id="triggerMe" href="openUnder.cfm" target="_blank" style="display:none;"></a> -->

    <a href="#" class="btn" data-href="http://www.cnn.com">Button</a>

  </body>

</html>

JavaScript

/*
$('#openUnder').on('click', function() {
  $('#triggerMe')[0].click();

  setTimeout(function() {
    window.location = 'http://www.cnn.com';
  }, 3000);
});
*/

$(".btn").on("click", function(e) {

  var href = $(this).data('href');

  window.open(window.location.href, '_blank');

  setTimeout(function() {
    window.location = href
  }, 2000);

});