2017-07-27 85 views
0

我正在构建一个具有文件输入的HTML5页面。如何在Android和iOS中禁用“输入类型=”文件“>禁用”拍照“选项

<input type=“file” > 

当我试图加载使用WebVivew的页面在iOS或Android应用程序的项目,我想禁用输入了“拍照”选项。

有没有解决方法?

谢谢大家。

此外,我已经尝试了解决方案:How to disable take photo on file input iOS 6,但它不起作用。

+0

https://stackoverflow.com/questions/16819845/how-to-disable-take-photo-on-file-input-ios-6 –

回答

0

userAngent在JavaScript中提供了有关浏览器和操作系统

navigator.userAgent的信息被用来获取浏览器和操作系统的详细信息。

“的Mozilla/5.0(Windows NT的10.0; Win64的; 64)为AppleWebKit/537.36(KHTML,例如Gecko)铬/ 59.0.3071.115 Safari浏览器/ 5xx.xx”是outuput如果我们运行在上面的命令弓手控制台。

例子:

var userAgent = navigator.userAgent || navigator.vendor || window.opera; 

//Android 
if(/android/i.test(userAgent)) 
{ 
    //run the android specific code 
    //In your case hide the Input 
} 

//iOS 
if(/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) 
{ 
    //run the iOS specific code 
    //In your case hide the Input 
} 

//Windows Phone 
if (/windows phone/i.test(userAgent)) { 
    //run the Windows specific code 
    //In your case hide the Input 
} 
+0

感谢您的帮助。但在我的情况下,我仍然想从这个输入中选择图片,虽然“从图库中选择”选项。我唯一想做的就是禁用“拍照”选项。 –