码迷,mamicode.com
首页 > 其他好文 > 详细

使用phonegap从相册里面获取照片

时间:2017-04-25 00:40:28      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:ring   使用   fail   eve   camera   add   ict   pac   false   

<!DOCTYPE html>

<html>
 
    <head>
        <meta charset="UTF-8">
        <title>Take a Photo</title>
 
        <script type="text/javascript" charset="UTF-8" src="cordova.js"></script>
        <script type="text/javascript" charset="UTF-8">
            document.addEventListener("deviceready", onDeviceReady, false);
 
            function onDeviceReady() {
            }
             
            //成功回调
            function onPhotoSuccess(imageURI){
                var myImage=document.getElementById(‘myImage‘);
                myImage.style.display=‘block‘;
                myImage.src=imageURI;
            }
             
            //失败回调
            function onPhotoFail(message){
                alert(‘Failed beacause:‘+message);
            }
             
            //获取照片
            function getPhoto(source){
                navigator.camera.getPicture(onPhotoSuccess,onPhotoFail,{quality:50,sourceType:source});
            }
             
        </script>
    </head>
 
    <body>
        <button onclick="getPhoto(Camera.PictureSourceType.PHOTOLIBRARY);"> From Photo Library</button><br>
        <img style="display:none;" id="myImage" src=""/>
    </body>
 
</html>

使用phonegap从相册里面获取照片

标签:ring   使用   fail   eve   camera   add   ict   pac   false   

原文地址:http://www.cnblogs.com/mhlu20909/p/6759635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!