开发者

How can I suppress keyboard popup on an iPad HTML5 app?

I’ve written an HTML5 application for iPad. It has one input field. Every time a user comes to t开发者_开发技巧his page, the popup keyboard appears.

How can I suppress this default behavior within HTML5/JS context?

In my app, if you type in a login & password, it shows another screen (without page reload). But the keyboard still exists, and you have to manually hide it.


I’m not sure I understand your description of your problem, it seems incomplete. Could I try re-stating it, to see if I understand correctly?

  1. The user opens Safari on the iPad
  2. The user types the address of your HTML5 app into Safari’s address bar, and taps the “Go” button
  3. The user is taken to your app’s login page. They tap into the username field, and the popup keyboard appears.
  4. They type in their username, switch to the password field, type in their password, and tap the “Go” button.
  5. Your app loads some different content on the screen via JavaScript. The popup keyboard is still present.

If that’s the problem you’re having, it might be worth calling the blur function on your username and password fields before you load the content of the new page. That might make the keyboard go away.

If the HTML for these fields looked like this:

<input type="text" name="username" id="username">
<input type="password" name="password" id="password">

Then the JavaScript would be:

document.getElementById('username').blur();
document.getElementById('password').blur();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜