2011-11-15 39 views
0

我定義爲我的應用程序中的ListPanel如下:打開外部網站/地址從煎茶觸摸應用

  //Create List View Using ListStore Created in data.js 
      SpotiPod.listPanel = new Ext.List({ 
       id: 'artistList', 
       store: SpotiPod.ListStore, 
       itemTpl: '<div>{ArtistName}</div>', 
       grouped: true, 
       indexBar: true, 
       listeners: { 
        itemtap: function(list, index){ 
         var rec = list.store.getAt(index) 
         //Ext.Msg.alert(rec.get('ArtistName'), 'Load In Spotify?', function(){location.href = rec.get('SpotifyURI');}); 
         Ext.Msg.show({ 
          title: rec.get('ArtistName'), 
          msg: 'Load In Spotify?', 
          buttons: Ext.MessageBox.YESNO, 
          fn: showSpotify 
          }); 
         function showSpotify(btn){ 
          if(btn == 'yes'){ 
           window.open(rec.get('SpotifyURI')); 
          } 
         } 
        } 
       } 
      }); 

的應用呈現藝術家的名單,並應使用Spotify的URI的,當提供一個鏈接到他們你點擊是加載Spotify它應該打開應用程序並顯示藝術家。下面的應用程序在iPhone上的瀏覽器和移動Safari瀏覽器中工作正常。但是,如果我將應用程序添加到主屏幕並運行它,那麼它不再有效。我收到一個錯誤消息,「URL無法顯示」。

有沒有人有任何想法可以改變這種方式來讓鏈接正確地被解僱?

乾杯

亞當

+0

什麼ü通過將應用程序添加到主屏幕是什麼意思? – heyjii

+0

正如我在移動Safari瀏覽器中的web應用程序的地址,即mydomain.com/mywebapp並運行鏈接以從此處發現將會工作並打開Spotify應用程序並加載正確的信息。如果我選擇「添加到主屏幕」並將應用程序放置在我的跳板上,則停止工作。 –

回答

0

這裏是我的煎茶論壇發現,我不知道,如果它這樣原諒我,如果它沒有。這個想法是創建一個錨點標記並模擬點擊而不是調用window.open()方法。這是從sencha post發佈的代碼。

Ext.util.openLink = function(href) { 
    var link = document.createElement('a'); 
    link.setAttribute('href', href); 
    link.setAttribute('target','_blank'); 
    var clickevent = document.createEvent('Event'); 
    clickevent.initEvent('click', true, false); 
    link.dispatchEvent(clickevent); 
return false; 
} 

http://www.sencha.com/forum/showthread.php?130358-window.open()-from-toolbar-button-opens-window-from-list-item-a-new-tab&p=639938#post639938