1

Sencha TouchPhonegap (cordova-2.0.0)を使用して Android 用のアプリを開発しています。

HTML を含む Ext.Panel があります。たとえば、次のようになります。

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

私の問題: デバイスでアプリを実行してリンクをタップすると、Android ブラウザーが URL を開き、アプリを終了します。

私の目的:デバイスでアプリを実行してリンクをタップすると、アプリはタップされたリンクを表示する必要があります。たとえば:

navigator.notification.alert(MyPage.html);

私のPhonegapコード(HTMLPanelにuniqueid.htmlを表示):

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',
    }
});  
4

1 に答える 1

2

Ext.Panel に表示される HTML コンテンツを制御できますか? はいの場合は、に変更<a href="MyPage.html">MyPage</a><a href="javascript:alert('MyPage.html');">MyPage</a>ます。

于 2012-09-26T12:35:17.130 に答える