我正在寫一個函數編輯這樣按鈕點擊沒有反應
<script type="text/javascript">
function share() {
var canvas = document.getElementById("myCanvas");
var imageObj = new Image();
imageObj.onload = function() {
contentW = $("#content").width();
canvas.width = 400;
canvas.height = 600;
context.drawImage(imageObj, 0, 0,canvas.width,canvas.height);
//the plugin
setTimeout(function(){
window.savephotoplugin(canvas,"image/png",device.version,function(val){
//returns you the saved path in val
alert("Photo Saved: " + val);
});
},0)
}
}
</script>
按鈕代碼
<div >
<IMG SRC="loadin.png" ALT="some text" WIDTH=100 HEIGHT=100>
<button class="button" id="myCanvas" onclick="share()">SEND </button>
</div>
但按鈕點擊後沒有事件被觸發後,將圖像保存phonegap應用程序。我的代碼是正確的,即使logcat輸出沒有錯誤,但爲什麼沒有得到輸出?請幫我
您正在使用永遠不會觸發的imageObj.onload。我錯過了什麼嗎? – zvona