/*******
works when "Take Photo" button clicked
********/
function takePicture() {
var result = blackberry.media.camera.takePicture(successCB);
}
/*******
post processing of photo click event
********/
function successCB(filePath) {
try{
blackberry.media.camera.close();
var imagePath = "file://" + filePath;
document.getElementById('images').setAttribute('src', imagePath.toString());
document.getElementById("photoDetails").innerHTML = imagePath;
}
catch(e) {
document.getElementById("photoDetails").innerHTML = e.ToString();
}
}
//ConfigFile includes the following, <access subdomains="false" uri="file:///store/home/user/camera/">
//html portion of viewing photo
<ul>
<li id="Li1">
<img id="Img1" alt="image" src="file:///store/home/user/camera/IMG-20120118-00001.jpg" /></li>
<li id="photoDetails">
<img id="images" alt="image" src="kkkoj" /></li>
</ul>
the imagePath variable successfully prints => “file:///store/home/user/camera/IMG-20120118-00001.jpg”. but the photo is not showing up.
i don’t understand whats the problem with the code i have written. image path came alright.
Strangely when i hardcode the imagePath as a src of image it can show the image. but when i set it using javascript in successCB(), it doesn’t work. i tested the functionality of my javascript code in firefox. it works in basic html. i am using Blackberry 9700 with os 6 bundle 2921. i need immediate help. please i am stuck with this for a whole day
You’re use of
document.getElementById("photoDetails").innerHTMLis the problem..innerHTMLreplaces everything in between the opening and closing tags of<li id="photoDetails">. Sinceimagesis inphotoDetails, it is getting erased with just the imagePath.If you want to display the imagePath, try adding a
<div>or<span>and updating them with the path.Also, I don’t think you need the
<access>element in your configuration file, since that is only used for accessing external servers.