2012-09-26 95 views
1

我使用Sencha TouchPhonegap(cordova-2.0.0)爲Android開發應用程序。Link tap打開Android瀏覽器並退出應用程序

我有它的一些HTML的Ext.Panel,例如:

<body> 
    <a href="MyPage.html">MyPage</a> 
</body> 

我的問題:當我運行在設備上的應用程序,然後點擊該鏈接,Android瀏覽器中打開URL並退出應用程序。

我的目標:當我運行在設備上的應用程序,然後點擊該鏈接時,應用程序應該表現出的螺紋連接,例如:

navigator.notification.alert(MyPage.html);

我的PhoneGap代碼(顯示UNIQUEID html的在HTMLPanel):

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystemSuccess, null); 

function onRequestFileSystemSuccess(fileSystem) { 
    fileSystem.root.getDirectory(Ext.ComponentQuery.query('#bibliothekDataView')[0].getSelection()[0].get('directory'), null, SelectedItemSuccess, SelectedItemFail); 
} 

//shows the uniqueid.html in the HTMLPanel 
function SelectedItemSuccess(dir) { 
    dir.getFile(record.get('id') + '.html', null, gotFileEntry, fail); 
} 

function SelectedItemFail() { 
    navigator.notification.alert("Failed to read file contents: " + error.code); 
} 

function gotFileEntry(file) { 
    file.file(gotFile, fail); 
} 

function gotFile(file) { 
    readAsText(file); 
} 

function readAsText(file) { 
    var reader = new FileReader(); 
    reader.onload = function (evt) { 
     Ext.ComponentQuery.query('#mainHTMLPanel')[0].setHtml(evt.target.result); 
    }; 

    reader.onerror = function() { 
     navigator.notification.alert("Failed to read file!"); 
    }; 
    reader.readAsText(file); 
} 

function fail(error) { 
    navigator.notification.alert("Failed to read file contents: " + error.code); 
} 

我HTMLPanel(查看):

Ext.define('myApp.view.HTMLPanel', { 
    extend: 'Ext.Panel', 
    xtype: 'mainhtmlpanel', 

    config: { 
     id: 'mainHTMLPanel', 
     scrollable: 'vertical', 
    } 
}); 
+0

需要看代碼.. – NewUser

+1

您需要註冊一個意圖,以捕捉意圖並打開應用程序。 – Leandros

回答

2

您是否可以控制Ext.Panel中顯示的HTML內容?如果是,則將<a href="MyPage.html">MyPage</a>更改爲<a href="javascript:alert('MyPage.html');">MyPage</a>

+0

對我來說,THX似乎是最簡單的解決方案 –

相關問題