A
A
Alex Kheben2011-10-05 23:40:08
JavaScript
Alex Kheben, 2011-10-05 23:40:08

Location.href and wheel click?

We have:

...
<tr onclick="location.href='/';">
<td><a href="/">text1</a></td>
<td><a href="/">text2</a></td>
<td>text3</td>
</tr>
...

When you click the left mouse button on any part of the line, everything is fine.
When you click the left mouse button on the link in the line, everything is just as normal.
When you click the middle mouse button (for many, this is a wheel) on a link in a line, you follow the link in a new tab and in an existing tab, although the second was somehow not expected. What is strange and does not happen in the Firefox browser, but in chrome it does not work “correctly”.
And so, the question is:
How to make it so that when you click the wheel on a link in a line, the page does not open in an existing tab, but opens as expected in a new tab?
It would be nice to know a cross-browser version of fixing this feature.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
philpirj, 2011-10-06
@philpirj

The "problem" of chromium. On a click with the middle button, it opens a new window.
If you want the main window to not go anywhere, add return false; in onclick, but the meaning of href is somewhat lost.

O
Oleg Yakovenko, 2011-10-06
@Apx

There is nothing surprising. You forcefully change the address
location.href='/'
. This is a piece of javascript, and you redefine href. Chrome just adequately fulfills everything, but ff is not.
Write a link like a human

T
tick, 2011-10-06
@tick

I don't understand what all this is for. Do you want the user to think that he will hit the default value of the link in a href, but on click he will get to the wrong place where the link leads? The phishing scheme turns out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question