0

In chrome standart behavour for ctrl+click is open link in new tab.

But inline js <a href="..." onclick="<some js>"> hinders to open in new tab with ctrl+click. It just opens link in same tab.

What is easiest way to provide a normal behavior by ctrl+click for this case?

zen
  • 980
  • 6
  • 18
  • Whats your actual intention? do you want the page open in new tab or ctrl + click then new tab? – Sankar Dec 26 '17 at 08:26
  • I want to provide standart behavour on ctrl+click. So if any link with inline js will ctrl+click, it will open in new tab. – zen Dec 26 '17 at 08:29
  • 1
    this is an answer using jQuery, but the basics are the same: https://stackoverflow.com/a/26823929/5269101 – VdeVentura Dec 26 '17 at 08:33

1 Answers1

1

If you can be a little more specific on what you want to do exactly, I might be able to help you more.

I am not quite sure on what your asking. But to use onclick to open a new tab. You can use the example below.

function tab(url) {
  var win = window.open(url, '_blank');
  win.focus();
}
<a onclick="tab('http://www.google.com');">New Tab</a>
ABC
  • 2,068
  • 1
  • 10
  • 21