使用PhoneGap调用Camera (android)
使用PhoneGap调用Camera (android)
效果图:
(function(){ $('#camera').live('pageshow',function(){ $('#takePhotoBtn').bind('click',function(){ navigator.camera.getPicture(onSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI }); }); function onSuccess(src) { $('#photo').attr('src',src); } function onFail(message) { alert('Failed because: ' + message); } }); })();
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="format-detection" content="telephone=no" /> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <link rel="stylesheet" type="text/css" href="css/website.css" /> <title>Camera with PhoneGap</title> </head> <body> <div id="camera" data-role="page"> <h3>使用PhoneGap调用相机(android)</h3> <div> <img id="photo" style="margin-left:40%;height:80px;width:80px;border:1px solid #ccc;" src="img/cordova.png"/> </div> <div> <a id="takePhotoBtn" data-role="button" data-theme="b">照相</a> </div> </div> <script type="text/javascript" charset="utf-8" src="js/cordova-2.3.0.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquery.mobile-1.2.0.min.js"></script> <script type="text/javascript" charset="utf-8" src="js/camera.js"></script> </body> </html>
相关推荐
quzishen 2013-07-17
故作坚强 2013-07-15
爱技术爱生活TAO 2013-07-06
临碣秘藏 2013-07-10
czpaex 2011-09-11
益之 2014-01-09
yxwang0 2014-01-09
朱莉的乔夫 2014-09-05
朱莉的乔夫 2015-03-26
朱莉的乔夫 2015-03-13
益之 2015-04-21
临碣秘藏 2015-05-12
quzishen 2016-01-20
爱技术爱生活TAO 2016-01-07
tenda 2012-09-08
临碣秘藏 2012-05-30
老菜鸟自习室 2012-04-07