views:

443

answers:

1

Mobile Safari on the iPhone allows you to specify different keyboard types for text input boxes as demonstrated in the Safari How-To's for iPhone, here. However, I'm wondering if it's possible to change keyboard type displayed when a Javascript prompt() dialog is displayed.

I know I can roll my own modal pop-up if I have to, but I'd like to know if it's possible to use the built-in prompt() function with a different keyboard (numeric, in my case).

Any ideas?

+2  A: 

I am pretty sure the answer is, unfortunately, "no". Consider the following experiment:

<html>
<head>
 <script type="text/javascript">
   function doit() {
     prompt("this is a test");
   }
 </script>
</head>
<body>
 <a href="javascript:doit();">Click me</a>
</body>
</html>

If you put that into an HTML page and load it into Mobile Safari, then turn your phone into landscape view, then click on the link, what do you expect to happen? What you'd expect to happen is for the prompt dialog to come up in landscape orientation with the wide keyboard. What actually happens is that Mobile Safari rotates back to portrait view and pops up the small keyboard, then rotates back after you enter your text. (For fun, alert the results, the alert rotates the display too...) Note that the HTML 5 customizations (type="tel" or pattern="[0-9]*") properly pop up landscape keyboards when appropriate.

Note that this is not a priori evidence that you can't customize the keyboard's appearance, but it is a pretty strong indicator that the javascript prompt behavior is bolted on and not well integrated into the rest of the user experience.

ddoughty
>the javascript prompt behavior is bolted on and not well integrated into the rest of the user experienceYep, that's my feeling too. *sigh*
Gabe Hollombe