我想通过键盘快捷键聚焦一个特殊的 id(在圆形立方体中)。html是
...
<div id="mainscreen">
<div id="messagetoolbar" class="toolbar">
<div id="mailview-left" style="width: 220px;">
<div id="mailview-right" style="left: 232px;">
...
我尝试了以下方法:
// Strg + Tab, um in Nachrichtenbereich zu kommen
...
else if (event.keyCode == 9 && event.ctrlKey) {
alert("taste erkannt");
//document.getElementById("messagetoolbar").focus();
//$("#messagetoolbar").focus();
setTimeout(function() { $('#messagetoolbar').focus(); alert("zeit"); }, 3000);
}
...
显示了第一个警报和第二个警报,但没有关注 id messagetoolbar。有人有想法吗?
非常感谢。
编辑:我想我应该更好地描述它:我想在圆形立方体的电子邮件收件箱中标记第一行/电子邮件。收件箱是一个带有 tr-tag 的表格...当我尝试您的解决方案时,第一行也是虚线,但是使用 enter 我无法打开邮件,使用其他键我无法标记第一行/邮件...我想我必须“模拟左键”才能标记第一行...?
现在我尝试使用 jquery 的 .trigger。收件箱表的 html 是
<table id="messagelist" class="records-table messagelist sortheader fixedheader">
<thead>
<tbody>
<tr id="rcmrow27428" class="message">
<td class="threads"></td>
<td class="date">16.04.2014 13:41</td>
<td class="fromto">
...
我试着用...
$('#messagelist tr').eq(1).addClass('message selected focused').removeClass('unfocused').trigger("click");
...但它不起作用:它添加了一个删除类但并没有真正关注该行:-(使用“按钮”它可以工作。
再次编辑:我认为 roundcube 的文件 list.js 对于这个问题很重要。在那里我发现了以下内容:
/**
* Set focus to the list
*/
focus: function(e)
{
var n, id;
this.focused = true;
for (n in this.selection) {
id = this.selection[n];
if (this.rows[id] && this.rows[id].obj) {
$(this.rows[id].obj).addClass('selected').removeClass('unfocused');
}
}
// Un-focus already focused elements (#1487123, #1487316, #1488600, #1488620)
// It looks that window.focus() does the job for all browsers, but not Firefox (#1489058)
$('iframe,:focus:not(body)').blur();
window.focus();
if (e || (e = window.event))
rcube_event.cancel(e);
},
有人知道如何修改或使用提及我的问题吗?谢谢!