如何使用javascript完全复制中间点击行为

时间:2011-10-28 19:32:22

标签: jquery mouseclick-event

我的网站上有一个表格,其上有标记的点击事件,因此它们就像链接一样。我正在尝试正确复制中间点击事件,因此它的行为方式与普通链接相同。

我在中间点击时打开了一个新选项卡,但是我想让新标签弹出而不是弹出(即不重点)。

有办法做到这一点吗?

以下是我目前工作的一些示例代码

<script type="text/javascript">
urlTemplate = '/library/edit/ID';
$(document).ready(function() {
    $('.row_link').mousedown(function(e){
        e.preventDefault();
        e.stopPropagation();
    });
    $('.row_link').mouseup(function(e){
        url = urlTemplate.replace('ID',$(this).attr('rel'));
        if(e.which === 1) {
            e.preventDefault();
            e.stopPropagation();
            document.location.href=url;
        }
        else if(e.which === 2) {
            e.preventDefault();
            e.stopPropagation();
            window.open(url);
        }
    });
});
</script>

...

<table id="document-index">
    <tr class="row_link" rel="4004">
        <td>IBTAKTF.pdf</td>
        <td>blah, blah, blah</td>
    </tr>
</table>

1 个答案:

答案 0 :(得分:0)