admin管理员组文章数量:1317909
Is there a way force the keyboard on iPad to close on blur of div 'contenteditable'??
Here is a basic jsfiddle: /
I'd like to have the keyboard close when a user clicks on the button.
Any thoughts super appreciated.
Thanks.
Is there a way force the keyboard on iPad to close on blur of div 'contenteditable'??
Here is a basic jsfiddle: http://jsfiddle/j_tufte/7HDmN/
I'd like to have the keyboard close when a user clicks on the button.
Any thoughts super appreciated.
Thanks.
Share Improve this question asked Jan 20, 2012 at 23:34 tuddytuddy 1,8344 gold badges31 silver badges36 bronze badges2 Answers
Reset to default 8As you have mentioned in your ment, element.blur()
unfortunately doesn't work on an editable div. But you could instead move the focus to an actual input field and remove it again right away:
$('#otherBox').on('click', function(){
$('#orInput').focus().blur();
});
(This uses your jsFiddle HTML code).
There are downsides to this approach: you need another input field (which you can't set to display: hidden
or visibility: hidden
, but you can set it's size to 0 and opacity: 0
). Also, the view may scroll to the location of this input field when the above handler is invoked. So you will need to place the second input field right next or behind to the editable div.
You will also need to take care of the input field not being targeted by the previous/next buttons: set it disabled.
<input id="orInput" disabled="disabled" style="width:0; height:0; opacity:0" type="text" />
For focussing/blurring you will then need to enable the field:
$('#otherBox').on('click', function(){
$('#orInput').removeAttr("disabled")
.focus().blur().attr("disabled", "disabled");
});
However, this is definitely a workaround. I haven't found any other solution yet (e.g. removing the contenteditable
attribute doesn't work) but I'd very much like to hear other ideas.
You should be able to do exactly that -- attach an event listener to the button and use it to blur()
the input field that caused the keyboard popup (use JavaScript to get a handle on that element and then call it's blur
method). That supposedly closes the iPad keyboard.
本文标签: javascriptClosing keyboard on iPad in div contenteditableStack Overflow
版权声明:本文标题:javascript - Closing keyboard on iPad in div contenteditable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742029242a2416125.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论