亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

電視機頂盒的瀏覽器不支持keyup事件,可以如何模擬?

電視機頂盒的瀏覽器不支持keyup事件,可以如何模擬?

一只甜甜圈 2018-09-03 19:06:27
事實用以下檢測代碼來檢測時,是支持Keyup的function detectEventSupport(eventName) {    var tempElement = document.createElement('div'),         isSupported;     eventName = 'on' + eventName;     isSupported = (eventName in tempElement); // 使用第一種方式     // 如果第一種方式行不通,那就來看看它是不是已知事件類型     if (!isSupported) {         tempElement.setAttribute(eventName, 'xxx');         isSupported = typeof tempElement[eventName] === 'function';        if(typeof tempElement[eventName] != 'undefined'){             tempElement.removeAttribute(eventName);         }     }    // 清除掉動態創建的元素,以便內存回收     tempElement = null;    // 返回檢測結果     return isSupported; }但實際上使用時并不會觸發。因此想模擬keyup事件var mock = null; addEvent(document, 'keydown', function(e) {     keydownHandler(e);    if (mock) clearTimeout(mock);     mock = setTimeout(function() {         keyupHandler(e);     }, 200); });但是這種方法的效果不是很好,請問還有沒有更好的方法
查看完整描述

1 回答

?
慕田峪9158850

TA貢獻1794條經驗 獲得超7個贊

厲害了我的哥!
alert 一下 navigator.userAgent 看看什么內核的呀

查看完整回答
反對 回復 2018-10-14
  • 1 回答
  • 0 關注
  • 601 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號