0

I've added some JS links to container divs on a WordPress website. This looks for any link within the container class and makes the entire div clickable. It works great except you can't control or command-click the divs in order to open a new tab. They just open in the same tab.

<script type="text/javascript"> jQuery(function($){
$(".entire-div-products-led-sign-link").click(function() {
  window.location = $(this).find("a").attr("href"); 
  return false;
});
}); </script>

Can someone help me figure out how to make these links open in a new tab using both the command (mac) and control (windows) keys?

  • Could be duplicate of https://stackoverflow.com/questions/6673473/jquery-go-to-url-with-target-blank – Chris Cousins May 09 '18 at 20:58
  • I only want it opening in a new tab via the control or command key like a normal link. Otherwise, I want it to open in the same window. – Taylor Latch May 09 '18 at 22:41

1 Answers1

0

Maybe you need to use window.open(url); instead of window.location

Reda Meskali
  • 275
  • 3
  • 9
  • It should be something like this:`if (e.metaKey || e.ctrlKey) return;` but i'm not sure how to integrate it in the above code. – Taylor Latch May 09 '18 at 22:48