在我的项目中我想使用
- Complete.ly(参见http://complete-ly.appspot.com http://complete-ly.appspot.com )
- 或 typeahead.js (参见http://twitter.github.io/typeahead.js/ http://twitter.github.io/typeahead.js/)
据我所知,这两个库都不支持移动设备,所以我需要处理这个问题。
就预输入而言,他们遇到了一个他们说不会解决的问题https://github.com/twitter/typeahead.js/issues/324 https://github.com/twitter/typeahead.js/issues/324
虽然我预计只有极少数用户使用移动设备(我的网络应用程序是某种仪表板,不太适合小屏幕),但我希望能够检测到这种情况,并至少能够为他们提供标准的 HTML输入文本。
有什么建议 ?
特别是对于complete.ly
首先,您应该找到一种方法来确定您是否在移动设备上运行。
see: 检测移动浏览器 https://stackoverflow.com/questions/11381673/javascript-solution-to-detect-mobile-browser
对于 Complete.ly 你可以这样做:
if (typeof window.orientation !== 'undefined') {
// mobile.
var input = document.createElement('input');
input.type = 'text'
...
document.getElementById('container').appendChild(input);
...
} else {
var completely = document.getElementById('container');
...
...
}
可以说,这可以由complete.ly 自己处理。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)