From 1b1ca1d3719aed156f4493a0de7cb16b2293a8da Mon Sep 17 00:00:00 2001 From: WayneXuan Date: Sat, 9 Jan 2016 09:32:12 +0800 Subject: [PATCH] =?UTF-8?q?Enter=E6=97=B6,=E5=A6=82=E6=9E=9C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E9=80=89=E4=B8=AD=E5=86=85=E5=AE=B9,$input=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=84=A6=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/javascript/popup.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/javascript/popup.js b/src/javascript/popup.js index 27b6924..f6f5854 100644 --- a/src/javascript/popup.js +++ b/src/javascript/popup.js @@ -378,9 +378,14 @@ toggleKey.onchange = function (event) { // updateSetting("duration", event.target.value); // }) -//在popup页内 Enter键 查询选中部分 +//在popup页内 Enter键 查询选中部分 如果没有选中部分,$input请求焦点 document.addEventListener('keyup',function(e){ if(document.activeElement.tagName=="BODY" && e.which==13){ - queryInPopup(window.getSelection().toString()); + var selection=window.getSelection().toString(); + if(selection.length>0) { + queryInPopup(selection); + }else{ + $input.focus(); + } } }); \ No newline at end of file