2

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

当我中键单击时,我让它打开了一个新标签,但我想让新标签弹出而不是弹出(即不集中注意力)。

有没有办法做到这一点?

这是我目前正在工作的一些示例代码

<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>
4

1 回答 1

0

尝试

window.focus();

http://www.w3schools.com/jsref/met_win_focus.asp

于 2012-02-17T01:18:13.813 回答