2014-03-04 18 views
0

因此,當我點擊作爲圖像但充當按鈕的「facebook按鈕」時,webview應該打開。 有沒有更好的方法來做到這一點,因爲這是行不通的。 它似乎很容易與雖然代碼..Webview不會在圖像上工作點擊

var fbbutton = Ti.UI.createImageView({ 
    image:"fb.png", 
    top:"55%", 
    zIndex:"1", 
    height:"15%", 
    width:"20%", 
    left:"2%" 
}); 

fbbutton.addEventListener("click" , function(e){ 
     var webview = Titanium.UI.createWebView({url:'http://www.facebook.com'}); 
    var window = Titanium.UI.createWindow(); 
    window.add(webview); 
    window.open(); 
}); 

回答

0

先給窗口明確的開放:

fbbutton.addEventListener("click" , function(e){ 
    var webview = Titanium.UI.createWebView({url:'http://www.facebook.com'}); 
    var window = Titanium.UI.createWindow(); 
    window.add(webview); 
    window.open({modal:true}); // Make modal 
});