简体   繁体   English

在iPhone上使用Mobile Safari时,使用prompt()Javascript功能是否可以更改键盘类型?

[英]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允许您为文本输入框指定不同的键盘类型,如适用于iPhoneSafari操作方法中所示 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.

相关问题 是否可以在Mobile Safari中使用Javascript在输入或文本区域上调用键盘? - Is it possible to invoke the Keyboard on an input or textarea using Javascript in Mobile Safari? 用户使用手机键盘键入内容时,我们可以触发javascript函数吗? - Can we fire javascript function when user type something using mobile keyboard Javascript TypeError:仅在 Safari 中使用 IntersectionObserver() 时出现类型错误 - Javascript TypeError: Type error when using IntersectionObserver() only in Safari 使用JavaScript在移动Safari上将值设置为输入类型=“日期” - Set a value to an input type=“date” on mobile Safari using JavaScript 使用javascript:history.go(-1)时,iPhone Safari Web App在新窗口中打开链接 - iPhone Safari Web App opens links in new window when using javascript:history.go(-1) createObjectURL:使用 Blob 时在 Safari 中键入错误 - createObjectURL: Type Error in Safari when using Blob 如何仅在使用IPhone / IPad时执行javaScript函数 - How to execute a javaScript function only when using an IPhone / IPad 当移动 safari 或 chrome 上的屏幕键盘打开时,是否会触发任何 javascript 事件? - Is there any javascript event fired when the on-screen keyboard on mobile safari or chrome opens? 使用蓝牙键盘时隐藏移动浏览器键盘。 - Hide mobile safari keyboard while using bluetooth keyboard. 移动Safari-使用Java键盘关闭 - Mobile Safari - Dismiss Keyboard with Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM