How to trap “open in a new tab” clicks in jquery.click

后端 未结 3 937
南方客
南方客 2021-02-10 08:47

I have a jquery script that attaches a click event to every link, running an action when the link is clicked. This has been working great, but I just got some betatester feedbac

3条回答
  •  庸人自扰
    2021-02-10 09:30

    See if you can somehow make use of jQuery rightclick plugin:

    http://abeautifulsite.net/notebook/68

    Usage:

    $(document).ready( function() {
    
        // Capture right click
        $("#selector").rightClick( function(e) {
            // Do something
        });
    
        // Capture right mouse down
        $("#selector").rightMouseDown( function(e) {
            // Do something
        });
    
        // Capture right mouseup
        $("#selector").rightMouseUp( function(e) {
            // Do something
        });
    
        // Disable context menu on an element
        $("#selector").noContext();
    
    });
    

    As for the cmd-clickie bit, I'm really not sure. In case it's helpful, here's the jQuery hotkeys plugin:

    http://www.webappers.com/2008/07/31/bind-a-hot-key-combination-with-jquery-hotkeys/

提交回复
热议问题