-1

Sorry for my stupid question but I really need it. I have a WP website, and there are social icons. So whenever user click on any social media icon, the clicked link should run in background tab and the user will remain stay on the same page (from where he/she clicked).

If there is any plugin or WP setting then please let me know. Thank you.

MD Sulaiman
  • 185
  • 1
  • 15

1 Answers1

0

This has been answered in many places: How to stay on current window when the link opens in new tab? This gives a good answer.

The overall answer is: Let the user decide - it is a user-set browser setting.

You can try to hack a way for Chrome users using the below code, but there are limitations!

function openNewBackgroundTab(){    
    var a = document.createElement("a");    
    a.href = "http://www.google.com/";    
    var evt = document.createEvent("MouseEvents");    

    //the tenth parameter of initMouseEvent sets ctrl key    
    evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,true, false, false, false, 0, null);    
    a.dispatchEvent(evt);
}