2012-01-18 53 views
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」。但照片沒有顯示出來。blackberry webworks:拍照後顯示拍攝圖像

我不明白我寫的代碼有什麼問題。圖像路徑來了。

奇怪的是,當我將imagePath作爲圖像的src進行硬編碼時,它可以顯示圖像。但是當我在successCB()中使用javascript設置它時,它不起作用。我在Firefox中測試了我的JavaScript代碼的功能。它在基本的HTML中起作用。我使用黑莓9700與OS 6捆綁2921.我需要立即幫助。請我堅持這一整天

回答

1

你使用document.getElementById("photoDetails").innerHTML是問題所在。 .innerHTML取代<li id="photoDetails">開始和結束標記之間的所有內容。由於imagesphotoDetails中,因此只會使用imagePath進行擦除。

如果要顯示imagePath,請嘗試添加<div><span>並使用路徑更新它們。

此外,我不認爲你的配置文件中需要<access>元素,因爲它僅用於訪問外部服務器。

+0

感謝core.B糾正我。我知道,但它並沒有出現在我的腦海裏。祝你今天愉快 – 2012-01-18 19:35:51