jQuery焦点()方法在ipad上 [英] JQuery focus() method on the ipad

查看:147
本文介绍了jQuery焦点()方法在ipad上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

iPad的HTML焦点


有谁知道如何获得focus()方法从jQuery的工作在iPad,或者也许是一个解决方法?我想要做的是让键盘弹出一个网页,因为我有jquery捕获击键来执行事件。但是,没有在页面上的文本框,我不知道如何让键盘弹出。现在,我已经在页面上的文本框,我试图使用jquery设置焦点到文本框,所以弹出的键盘。最重要的是,我将文本框样式设置为显示:无,以便焦点转到文本框,但没有看到,所以功能似乎工作。但是,焦点()是打破了iPad的!任何人都可以帮我吗?

解决方案

不幸的是,获取键盘显示的唯一方法是在用户启动事件期间。这是我最近一直在跟自己争吵的事情。

下面, ilumin 有一个很好的解决方案,但它不是唯一的。基本上,从我发现的情况来看,只要您在用户事件(例如mouseup或任何触摸事件[可能是触摸设备首选])内执行.focus()函数调用,那么你应该没有问题。

在某种程度上,我明白苹果为什么会这样做,但同时也使我的工作非常具有挑战性。

Possible Duplicate:
iPad HTML Focus

Does anyone know how to get the focus() method from jquery to work on the ipad, or perhaps a workaround? What I'm trying to do is to get the keyboard to pop up on a webpage since I have jquery capturing keystrokes to perform events. However, without a textbox on the page I don't know how to get the keyboard to pop up. Now that I have the textbox on the page, I'm trying to use jquery to set the focus to the textbox so the keyboard pops up. On top of this, I'm setting the textboxs style to display:none, so that the focus goes to the textbox but it's not seen, so the functionality appears to work. However, focus() is broken on the ipad! Can anyone help me?

解决方案

Unfortunately, the only way to get a keyboard to show, is during a user initiated event. This is something I've been fighting with myself as of late.

Below, ilumin has a good solution, but it's not the only one. Basically, from what I've found, as long as your are performing your .focus() function call inside of a user event (such as mouseup, or any of the touch events [which is probably preferred for a touch device]), then you shouldn't have a problem.

To an extent I understand why Apple made this limitation, but at the same time, it has made my work very challenging.

这篇关于jQuery焦点()方法在ipad上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆