本文介绍了检测与要么complete.ly或预输入在移动设备上禁用自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我想请使用

In my project I want to use either


  • complete.ly(见)

  • 或typeahead.js(见)

  • complete.ly (see http://complete-ly.appspot.com )
  • or typeahead.js (see http://twitter.github.io/typeahead.js/)

据我所知,没有这两个库的支持移动设备,所以我需要处理的。
至于预输入的推移,他们有一个问题,他们说,他们不会解决

As far as I know, none of the two libraries support mobile devices so I need to handle that. As far as typeahead goes they have an issue that they said they are not going to fix https://github.com/twitter/typeahead.js/issues/324

虽然我希望极少数使用移动设备的用户(我的web应用程序是有些还挺仪表板并没有真正适合小屏幕上)我希望能够检测这种情况下,至少能够给他们一个标准的HTML输入文本。

Although I expect a very small number of users using a mobile device (my web app is some kinda dashboard and not really suitable on small screens) I would like to be able to detect that case and at least being able to give them a standard HTML input text.

有什么建议?

特别是对于complete.ly

Particularly for complete.ly

推荐答案

首先,你应该找到一种方法来确定您是否在移动正在运行。

First you should find a way to determine if you are running on the mobile or not.

请参见:JavaScript.解决方案来检测手机浏览器

有关complete.ly你可以做这样的事情:

For complete.ly you could do something like this:

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自行处理。

arguably this could be handled by complete.ly itself.

这篇关于检测与要么complete.ly或预输入在移动设备上禁用自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 01:48