0
    /*******
    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>

imagePath 变量成功打印 =>“file:///store/home/user/camera/IMG-20120118-00001.jpg”。但照片没有出现。

我不明白我写的代码有什么问题。图片路径没问题。

奇怪的是,当我将 imagePath 硬编码为图像的 src 时,它可以显示图像。但是当我在successCB()中使用javascript设置它时,它不起作用。我在 Firefox 中测试了我的 javascript 代码的功能。它适用于基本的html。我正在使用带有 os 6 bundle 2921 的 Blackberry 9700。我需要立即帮助。请我坚持一整天

4

1 回答 1

1

你用的document.getElementById("photoDetails").innerHTML是问题。.innerHTML替换 . 的开始和结束标签之间的所有内容<li id="photoDetails">。由于images在 中photoDetails,因此仅使用 imagePath 即可将其擦除。

如果要显示 imagePath,请尝试添加<div><span>并使用路径更新它们。

另外,我认为您不需要<access>配置文件中的元素,因为它仅用于访问外部服务器。

于 2012-01-18T19:11:38.730 回答