zen
zen

Reputation: 992

how to prevent javascript blocking of open new tab with ctrl+click

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?

Upvotes: 0

Views: 377

Answers (1)

ABC
ABC

Reputation: 2148

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>

Upvotes: 1

Related Questions