1

I'm working with phpbb3 template now, and I want entire rows to be links to forums/topics. I tried making it without any scripts, but i feel it's too much messing up with the code.

Now I'm using

<tr onclick="window.location.href=http://example.com" />

but I want the link also open up in new tab on scroll click. Is there any method to attach window.open function to scroll click?

sonia
  • 317
  • 2
  • 15

1 Answers1

0

If you're using jQuery:

$("tr").mousedown(function(e) {
    if(e.which == 2)
    {
        window.location = $(this).attr("onclick").replace('window.location.href=','');
    }
} );

Plain ol' javascript:

document.onclick = function(e)
{
    if(e.which == 2 && e.target.tagName == 'TR')
    {
        var loc = e.target.getAttribute('onclick').replace('window.location.href=','');
        window.location = loc;
    }
}
MDEV
  • 10,730
  • 2
  • 33
  • 49
  • isn't 2nd button a middle button, which is not the same as scroll? I tried it before, this method is not working... – sonia Oct 21 '11 at 20:27
  • your original question states a scroll 'click' - the middle mouse button is the only scroll related click I know of I'm afraid. What were you actually referring to? If the page is scrolled, change URL? – MDEV Oct 21 '11 at 20:55
  • well, as far as i know, scroll click is not the "2" button. But, if you're sure it should work, please show me on this fiddle: http://jsfiddle.net/YRyzF/6/ – sonia Oct 21 '11 at 21:46
  • You used an id reference as tagname, just changing the value to 'DIV' or tagName to id fixed it: http://www.jsfiddle.net/YRyzF/11/ – MDEV Oct 21 '11 at 22:55