I have a PhoneGap HTML5 file as follows (only showing part of the head),
<head>
<script type="text/javascript" src="Javascript/phonegap-1.3.0.js"></script>
<!--<script type="text/javascript" src="Javascript/photo.js"></script>-->
<script>
function takePhoto()
{
alert("Take Photo");
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA});
}
function onSuccess(imageData)
{
var image = document.getElementById('photoImg');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message)
{
alert('Failed because: ' + message);
}
</script>
</head>
In the body I have this markup,
<button onclick='takePhoto()'>Take Photo</button>
Having it defined like above works fine. The problem is that I don't want to define the javascript in my html document. I want it to look like this,
<script type="text/javascript" src="Javascript/phonegap-1.3.0.js"></script>
<script type="text/javascript" src="Javascript/photo.js"></script>
And have photo.js contain the takePhoto method. I cannot get it to work like that. In my javascript console I get the error,
Uncaught ReferenceError: takePhoto is not defined at file:///android_asset/www/index.html:81