[英]Is it possible to change the keyboard type when using the prompt() Javascript function when using Mobile Safari on the iPhone?
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 . iPhone上的Mobile Safari允许您为文本输入框指定不同的键盘类型,如适用于iPhone的Safari操作方法中所示 。 However, I'm wondering if it's possible to change keyboard type displayed when a Javascript prompt() dialog is displayed.
但是,我想知道在显示Javascript提示符()对话框时是否可以更改显示的键盘类型。
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). 我知道如果必须的话我可以滚动自己的模态弹出窗口,但我想知道是否可以使用内置的prompt()函数和不同的键盘(在我的例子中是数字)。
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? 如果您将其放入HTML页面并将其加载到Mobile Safari中,然后将手机变为横向视图,然后单击链接,您希望发生什么? 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.
实际发生的是Mobile Safari旋转回纵向视图并弹出小键盘,然后在输入文本后旋转回来。 (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.
(为了好玩,提醒结果,警报也会旋转显示...)请注意,HTML 5自定义(type =“tel”或pattern =“[0-9] *”)会在适当时正确弹出横向键盘。
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. 请注意,这不是您无法自定义键盘外观的先验证据,但它是一个非常强大的指示,即javascript提示行为被固定并且没有很好地集成到其余的用户体验中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.