pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <i id='wsy0J'><tr id='wsy0J'><dt id='wsy0J'><q id='wsy0J'><span id='wsy0J'><b id='wsy0J'><form id='wsy0J'><ins id='wsy0J'></ins><ul id='wsy0J'></ul><sub id='wsy0J'></sub></form><legend id='wsy0J'></legend><bdo id='wsy0J'><pre id='wsy0J'><center id='wsy0J'></center></pre></bdo></b><th id='wsy0J'></th></span></q></dt></tr></i><div class="yt0kdor" id='wsy0J'><tfoot id='wsy0J'></tfoot><dl id='wsy0J'><fieldset id='wsy0J'></fieldset></dl></div>

      <bdo id='wsy0J'></bdo><ul id='wsy0J'></ul>

    <small id='wsy0J'></small><noframes id='wsy0J'>

  • <tfoot id='wsy0J'></tfoot>

    <legend id='wsy0J'><style id='wsy0J'><dir id='wsy0J'><q id='wsy0J'></q></dir></style></legend>

      1. 使用 JavaScript 模擬 tab 按鍵

        Simulating a tab keypress using JavaScript(使用 JavaScript 模擬 tab 按鍵)

          • <small id='y2rBA'></small><noframes id='y2rBA'>

            <tfoot id='y2rBA'></tfoot>
          • <legend id='y2rBA'><style id='y2rBA'><dir id='y2rBA'><q id='y2rBA'></q></dir></style></legend>

              <i id='y2rBA'><tr id='y2rBA'><dt id='y2rBA'><q id='y2rBA'><span id='y2rBA'><b id='y2rBA'><form id='y2rBA'><ins id='y2rBA'></ins><ul id='y2rBA'></ul><sub id='y2rBA'></sub></form><legend id='y2rBA'></legend><bdo id='y2rBA'><pre id='y2rBA'><center id='y2rBA'></center></pre></bdo></b><th id='y2rBA'></th></span></q></dt></tr></i><div class="xeypj5p" id='y2rBA'><tfoot id='y2rBA'></tfoot><dl id='y2rBA'><fieldset id='y2rBA'></fieldset></dl></div>
              • <bdo id='y2rBA'></bdo><ul id='y2rBA'></ul>

                  <tbody id='y2rBA'></tbody>
                • 本文介紹了使用 JavaScript 模擬 tab 按鍵的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想讓瀏覽器的行為就像用戶在點擊某物時按下了 Tab 鍵一樣.在點擊處理程序中,我嘗試了以下方法:

                  I'd like to have the browser act as if the user had pressed the Tab key when they click on something. In the click handler I've tried the following approaches:

                  var event = document.createEvent('KeyboardEvent');
                  event.initKeyEvent("keypress", true, true, null, false, false, false, false, 9, 0);
                  this.input.focus()[0].dispatchEvent(event);
                  

                  還有 jQuery:

                  this.input.focus().trigger({ type : 'keypress', which : 9 });
                  

                  ...我取自這里.

                  第一種方法似乎是最好的選擇,但不太奏效.如果我將最后兩個參數更改為 98、98,實際上,在輸入框中輸入了一個b".但是 9, 0 和 9, 9(我直接從 MDC 網站獲取的前者)在 FF3 下的 firebug 中都給了我這些錯誤:

                  The first approach seems to be the best bet, but doesn't quite work. If I change the last two parameters to 98, 98, indeed, a 'b' is typed into the input box. But 9, 0 and 9, 9 (the former of which I took right from the MDC web site) both give me these errors in firebug under FF3:

                  Permission denied to get property XULElement.popupOpen
                  [Break on this error] this.input.focus()[0].dispatchEvent(event);
                  
                  Permission denied to get property XULElement.overrideValue
                  [Break on this error] this.input.focus()[0].dispatchEvent(event);
                  
                  Permission denied to get property XULElement.selectedIndex
                  [Break on this error] this.input.focus()[0].dispatchEvent(event);
                  
                  Permission denied to set property XULElement.selectedIndex
                  [Break on this error] this.input.focus()[0].dispatchEvent(event);
                  

                  我聽說此類(沒有明確定義此類")事件是不受信任的",這可能解釋了這些錯誤.

                  I've heard such (with no clear definition of 'such') events are 'untrusted', which might explain these errors.

                  第二種方法會導致我作為 event.which 輸入的任何值都作為 event.which 傳遞,但沒有效果(即使我使用 98 而不是 9,也不會在框中輸入b".)如果我嘗試在我傳遞的對象中設置 event.data,當事件被觸發時,它最終是未定義的.以下是我用來查看的代碼:

                  The second approach causes whatever value I put as event.which to be passed as event.which, but to no effect (even if I use 98 instead of 9, no 'b' is typed in the box.) If I try setting event.data in the object I'm passing, it ends up undefined when the event is triggered. What follows is the code I'm using to view that:

                  $('#hi').keypress(function(e) {
                    console.log(e);
                  });
                  

                  還有其他想法嗎?

                  推薦答案

                  我最終采用的解決方案是創建一個焦點竊取器" div(tabindex = -1--可以有焦點但不能選項卡最初)在我想要手動管理焦點的區域的任一側.然后我放置了一個冒泡的真實事件監聽器,用于對整個區域進行聚焦和模糊處理.當該區域發生任何焦點時,tabindex 值將更改為 -1,當發生任何模糊時,它們將更改為 0.這意味著當焦點在該區域時,您可以使用 tab 或 shift-tab 離開它并且正確地結束在其他頁面元素或瀏覽器 UI 元素上,但是一旦您離開那里,焦點竊取器就會變成可選項卡,并且在焦點上它們正確設置手動區域并將焦點轉移到最后的元素上,就像您單擊了手動區域的一端或另一端一樣.

                  The solution I ended up going with is to create a "focus stealer" div (with tabindex = -1--can have the focus but can't be tabbed to initially) on either side of the area in which I want to manually manage the focus. Then I put a bubbling-true event listener for focus and blur on the whole area. When any focus occurs on the area, the tabindex values are changed to -1, and when any blur occurs, they're changed to 0. This means that while focused in the area, you can tab or shift-tab out of it and correctly end up on other page elements or browser UI elements, but as soon as you focus out of there, the focus stealers become tabbable, and on focus they set up the manual area correctly and shunt the focus over to the element at their end, as if you had clicked on one end or the other of the manual area.

                  這篇關于使用 JavaScript 模擬 tab 按鍵的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Use IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
                  anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 項目中不起作用)
                  Ionic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用異步數據更新 Observable)
                  Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
                  In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何創建使用 Ionic 組件的自定義指令?)
                  Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(將 ViewChild 用于動態元素 - Angular 2 amp;離子2)

                  • <tfoot id='fiZ3P'></tfoot>

                    <small id='fiZ3P'></small><noframes id='fiZ3P'>

                    <legend id='fiZ3P'><style id='fiZ3P'><dir id='fiZ3P'><q id='fiZ3P'></q></dir></style></legend>

                      <tbody id='fiZ3P'></tbody>

                          <bdo id='fiZ3P'></bdo><ul id='fiZ3P'></ul>

                            <i id='fiZ3P'><tr id='fiZ3P'><dt id='fiZ3P'><q id='fiZ3P'><span id='fiZ3P'><b id='fiZ3P'><form id='fiZ3P'><ins id='fiZ3P'></ins><ul id='fiZ3P'></ul><sub id='fiZ3P'></sub></form><legend id='fiZ3P'></legend><bdo id='fiZ3P'><pre id='fiZ3P'><center id='fiZ3P'></center></pre></bdo></b><th id='fiZ3P'></th></span></q></dt></tr></i><div class="023hele" id='fiZ3P'><tfoot id='fiZ3P'></tfoot><dl id='fiZ3P'><fieldset id='fiZ3P'></fieldset></dl></div>
                            主站蜘蛛池模板: 北京浩云律师事务所-企业法律顾问_破产清算等公司法律服务 | 地源热泵一体机,地源热泵厂家-淄博汇能环保设备有限公司 | 湖南教师资格网-湖南教师资格证考试网 | 招商帮-一站式网络营销服务|搜索营销推广|信息流推广|短视视频营销推广|互联网整合营销|网络推广代运营|招商帮企业招商好帮手 | 智成电子深圳tdk一级代理-提供TDK电容电感贴片蜂鸣器磁芯lambda电源代理经销,TDK代理商有哪些TDK一级代理商排名查询。-深圳tdk一级代理 | 多功能真空滤油机_润滑油全自动滤油机_高效真空滤油机价格-重庆润华通驰 | 深圳天际源广告-形象堆头,企业文化墙,喷绘,门头招牌设计制作专家 | 影合社-影视人的内容合作平台| 河南mpp电力管_mpp电力管生产厂家_mpp电力电缆保护管价格 - 河南晨翀实业 | 钢衬玻璃厂家,钢衬玻璃管道 -山东东兴扬防腐设备有限公司 | 两头忙,井下装载机,伸缩臂装载机,30装载机/铲车,50装载机/铲车厂家_价格-莱州巨浪机械有限公司 | 农业四情_农业气象站_田间小型气象站_智慧农业气象站-山东风途物联网 | 临沂招聘网_人才市场_招聘信息_求职招聘找工作请认准【马头商标】 | 矿用履带式平板车|探水钻机|气动架柱式钻机|架柱式液压回转钻机|履带式钻机-启睿探水钻机厂家 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | 新能源汽车电池软连接,铜铝复合膜柔性连接,电力母排-容发智能科技(无锡)有限公司 | 防水套管_柔性防水套管_刚性防水套管-巩义市润达管道设备制造有限公司 | 车牌识别道闸_停车场收费系统_人脸识别考勤机_速通门闸机_充电桩厂家_中全清茂官网 | 低合金板|安阳低合金板|河南低合金板|高强度板|桥梁板_安阳润兴 北京租车牌|京牌指标租赁|小客车指标出租 | 包装盒厂家_纸盒印刷_礼品盒定制-济南恒印包装有限公司 | 西点培训学校_法式西点培训班_西点师培训_西点蛋糕培训-广州烘趣西点烘焙培训学院 | 电销卡_北京电销卡_包月电话卡-豪付网络 | 武汉宣传片制作-视频拍摄-企业宣传片公司-武汉红年影视 | 上海平衡机-单面卧式动平衡机-万向节动平衡机-圈带动平衡机厂家-上海申岢动平衡机制造有限公司 | 中药超微粉碎机(中药细胞级微粉碎)-百科 | 固诺家居-全屋定制十大品牌_整体衣柜木门橱柜招商加盟 | 合肥网络推广_合肥SEO网站优化-安徽沃龙First | 高压油管,液压接头,液压附件-烟台市正诚液压附件 | 包装盒厂家_纸盒印刷_礼品盒定制-济南恒印包装有限公司 | 潜水搅拌机-双曲面搅拌机-潜水推进器|奥伯尔环保 | 北京网站建设|北京网站开发|北京网站设计|高端做网站公司 | 欧必特空气能-商用空气能热水工程,空气能热水器,超低温空气源热泵生产厂家-湖南欧必特空气能公司 | 冷藏车厂家|冷藏车价格|小型冷藏车|散装饲料车厂家|程力专用汽车股份有限公司销售十二分公司 | 沉降天平_沉降粒度仪_液体比重仪-上海方瑞仪器有限公司 | 培训中心-翰香原香酥板栗饼加盟店总部-正宗板栗酥饼技术 | 钢绞线万能材料试验机-全自动恒应力两用机-混凝土恒应力压力试验机-北京科达京威科技发展有限公司 | Honsberg流量计-Greisinger真空表-气压计-上海欧臻机电设备有限公司 | 锂电叉车,电动叉车_厂家-山东博峻智能科技有限公司 | 护栏打桩机-打桩机厂家-恒新重工| 能量回馈_制动单元_电梯节能_能耗制动_深圳市合兴加能科技有限公司 | 长沙一级消防工程公司_智能化弱电_机电安装_亮化工程专业施工承包_湖南公共安全工程有限公司 |