简体   繁体   English

寻找ibooks html输入替代

[英]Looking for ibooks html input alternative

In IOS5 on the iPad, iPad2 etc. iBooks accepted <input type="color"> as a way to prompt the keyboard to display when you clicked on an input field, to say, type in the answer to a question. 在iPad,iPad2等的IOS5中,iBooks接受<input type="color">作为当您单击输入字段时提示键盘显示的一种方式,也就是说,键入问题的答案。 I've just recently updated to IOS6, and this workaround no longer seems to be working. 我最近才更新到IOS6,并且这种解决方法似乎不再起作用。 I tried using the JavaScript I found here - http://www.linkedin.com/groups/How-Show-iPads-Keyboard-when-3877009.S.84287009 我尝试使用在这里找到的JavaScript- http://www.linkedin.com/groups/How-Show-iPads-Keyboard-when-3877009.S.84287009

<script type="text/javascript"> 

function iPadTouchHandler(event) { 
var type = "", 
button = 0; /*left*/ 

if (event.touches.length > 1) 
return; 

switch (event.type) { 
case "touchstart": 

// OLD: On iPad2 clicking on a text input field did not show the keyboard 
//  if ($(event.changedTouches[0].target).is("select")) { 
// NEW: Now on iPad2 the touchstart-Event on input fields is ignored and everything         works fine 
// change my by Roland Caspers, Scheer Management 
if ($(event.changedTouches[0].target).is("select") ||     $(event.changedTouches[0].target).is("input")) { 

return; 
} 
iPadTouchStart(event); /*We need to trigger two events here to support one touch drag     and drop*/ 
event.preventDefault(); 
return false; 
break; 
</script> 

However this code seems to be outdated and relevant to IOS5. 但是,此代码似乎已过时,并且与IOS5相关。 I know of a workaround, which is to put the page with the input into an iFrame, in that case you can just use <input type="text">, however I'd prefer to stay away from iFrames as they tend to move the content around depending on where the input box is. 我知道一种解决方法,即将带有输入的页面放入iFrame,在这种情况下,您可以使用<input type =“ text”>,但是我宁愿远离iFrame,因为它们会移动周围的内容取决于输入框的位置。 Any thoughts as to other possible solutions or workarounds? 对其他可能的解决方案或解决方法有什么想法? Tyvm :) Tyvm :)

I am also Facing the same issue on iOS6 for , the same is working perfectly on the <iframe> tag. 我也在iOS6上遇到同样的问题,在<iframe>标记上也可以完美地工作。 But it omits the images & style and etc. 但是它省略了图像和样式等。

Review the code " http://www.linkedin.com/groups/How-Show-iPads-Keyboard-when-3877009.S.84287009 ", I feel some thing has to modify on below condition: 查看代码“ http://www.linkedin.com/groups/How-Show-iPads-Keyboard-when-3877009.S.84287009 ”,我觉得有些事情必须在以下条件下进行修改:

($(event.changedTouches[0].target).is("select") ||     $(event.changedTouches[0].target).is("input"))

I'd be great if anyone provide the earlier response. 如果有人能提供较早的答复,我会很棒。

Thanks 谢谢

I struggled with this same problem in iBooks on iOS 7. The tricky part was, that iBooks probably makes all text input fields disabled by default. 我在iOS 7的iBooks中遇到了同样的问题,棘手的部分是,iBooks可能默认情况下禁用了所有文本输入字段。 We are using prototype.js, so here is my solution written for prototype: 我们正在使用prototype.js,因此这是我为原型编写的解决方案:

$('my-input-field-id').observe('touchstart', function(event) {
    var element = event.element();
    if (element.disabled)
        element.disabled = false;
    element.focus();
    event.stop();
});

So just listen for the 'touchstart' event on the input field and enable and focus the field when touched. 因此,只需在输入字段上监听“ touchstart”事件,然后在触摸时启用并聚焦该字段即可。 It works for ordinary text fields ( <input type="text"> ). 它适用于普通文本字段( <input type="text"> )。 Simple :-). 简单:-)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM