-2

Possible Duplicate:
How to distinguish between left and right mouse click with jQuery?

On right click I want to go to a different page..using jquery, how to do that? any idea?

thanks-

Community
  • 1
  • 1
subho das
  • 391
  • 4
  • 7
  • 15

1 Answers1

0

Something like this:

HTML

<a id="test" href=#">Click me</a>

JQuery

$(document).ready(function() {
    $("#test").mousedown(function(e) {
        switch (e.which) {
            case 1:
                alert("Left click... boring!");
                break;
            case 3:
                alert("Right-click... off to new page...");
                window.top.location = "http://www.google.com/";
                break;
        }
    })
});

JSFiddle here

njr101
  • 9,499
  • 7
  • 39
  • 56