ale*_*ire 15 android web-applications ios
我有一个关于从浏览器访问相机的问题.(Android和iOS浏览器)
谷歌和苹果公司在1年前宣布,从浏览器到相机的访问很快就会推出.
我需要这个功能用于移动Web应用程序.
此功能现在可用吗?
小智 10
尝试以下方法:
<html>
<body>
<form>
<input type="file" accept="image/*;capture=camera"/>
<input type="submit"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
正如他们在这里所说的,我确实使用了输入,并且在iOs上工作得非常好.我可以从相机或相册中获取图片并设置img元素.
这是代码:http://jsfiddle.net/2wZgv/
js:
<script>
oFReader = new FileReader();
oFReader.onload = function (oFREvent) {
document.getElementById("fotoImg").src = oFREvent.target.result;
document.getElementById("fotoImg").style.visibility = "visible";
var screenHeight = screen.availHeight;
screenHeight = screenHeight - 220;
document.getElementById("fotoImg").style.height = screenHeight;
};
$(function() {
$("input:file").change(function (){
var input = document.querySelector('input[type=file]');
var oFile = input.files[0];
oFReader.readAsDataURL(oFile);
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
这是w3c草案
读完后输入标签应该是
<input type="file" accept="image/*" capture="camera" id="capture">
Run Code Online (Sandbox Code Playgroud)
小智 -1
这个有可能。您可以通过浏览器应用程序访问相机。如果您通过 Phone Gap 进行开发,请查找http://docs.phonegap.com/phonegap_camera_camera.md.html
这是PhoneGap中用于访问相机的相机API。
| 归档时间: |
|
| 查看次数: |
43250 次 |
| 最近记录: |