[英]Button click in javascript doesn't respond
我正在寫一個函數來像這樣編輯后保存圖像
<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輸出沒有錯誤,我的代碼也是正確的,但是為什么不獲取輸出呢? 請幫我
避免使用img.onload
,它對於緩存的圖像可能不會觸發。 但是您可以向img src添加一些隨機值,例如
<img src="path/to/pic.jpg?r=1381257249" />
而且我看不到您將創建的imageObj
附加到DOM,因此不會觸發任何事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.