我用 jQuery 编写了以下代码:
$(document).on("click", "#datatable-responsive tbody tr td button.btn", function () {
window.open('somelinkhere', '_blank');
});
所以这里的问题是,当我这样做时,它工作完美,打开的新选项卡获得焦点,我不希望发生这种情况。相反,我想模拟这两个击键:ctrl + 鼠标左键单击
以便我的主窗口保持焦点并打开新选项卡...
我怎样才能在 jQuery 中做到这一点?
最佳答案
一种解决方案可能是:
$(document).ready(function() {
$("#datatable-responsive tbody tr td button.btn").click(function() {
var thisWind = window.location;
window.location = ('http://www.google.lt');
window.open(thisWind, '_blank');
});
})
非常简单 - 第一个窗口位置更改为弹出 URL,然后重新打开主窗口。
关于javascript - jQuery在点击事件打开新选项卡时模拟ctrl + click,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44002925/