Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (36 sloc) 1.08 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cordova Camera Example</title>
<style>
img { float: left; margin: 5px; width: 100px; height: 100px; }
</style>
</head>
<body>
<section>
<button>Take picture</button>
</section>
<script src="cordova-1.7.0.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function () {
document.addEventListener('deviceready', function () {
var button = document.querySelector('button');
var onSuccess = function (files) {
var img = document.createElement('img');
img.src = files[0].fullPath;
document.body.appendChild(img);
};
var onError = function () {
alert('capture error');
};
var onClick = function () {
navigator.device.capture.captureImage(onSuccess, onError);
};
button.addEventListener('click', onClick);
});
});
</script>
</body>
</html>