在 themeablebrowser Cordova/Phonegap 中获取页面标题

Get page title in themeablebrowser Cordova/ Phonegap

嗨,我正在使用 Cordova v3.7 和 themeablebrowser Cordova plugin 想要在 themeablebrowser 中获取页面标题,我无法获取。我已经按照文档中的说明尝试了 executeScript,但应用程序崩溃了。这是我到目前为止所做的。

function innAppInit(_url) {
    app.Log('browser news link=' + _url);
    if (_url == null) {
        _url = 'http://apache.org';
    }
    var ref = cordova.ThemeableBrowser.open(_url, '_blank', {

        backButtonCanClose: false,
        hideForwardButton: true,
        toolbarColor: '#239EC9',
        titleColor: '#FFFFFF',
        statusbarColor: '#239EC9',
        navButtonAlign: 'left',
        closeButtonAlign: 'right',
        menuButtonAlign: 'right',
        titleStaticText: 'Add New Web Page',

        menuButtonImage: 'themeablebrowser_stub_menu',
        menuButtonPressedImage: 'themeablebrowser_stub_menu_highlight',
        closeButtonImage: 'themeablebrowser_stub_close',
        closeButtonPressedImage: 'themeablebrowser_stub_close_highlight',
        backButtonImage: 'themeablebrowser_stub_back',
        backButtonPressedImage: 'themeablebrowser_stub_back_highlight',
        // menuTitle: 'Add Url to list',
        menuCancel: 'Cancel',
        menuItems: [{
            event: 'event_getURL',
            label: 'Add'
        }]
    }); 

    ref.addEventListener('loadstart', function(event) {
        try {
            app.Log('loadstart function');
            $('.ui-loader').show();

        } catch (e) {
            app.ErrorLog(e);
        }
    });
    ref.addEventListener('loadstop', function(event) {
        try {
            app.Log('loadstop function');
            $('.ui-loader').hide();


             ref.executeScript({
                    code: 'return document.title'
                },
                function(values) {
                    alert(values);                       
                });

        } catch (e) {
            app.ErrorLog(e);
        }
    });
    ref.addEventListener('event_getURL', function(event) {
        try {

            var url = event.url;
            app.Log('get url=' + url);          
            ref.close();

        } catch (e) {
            app.ErrorLog(e);
        }
    });
    ref.addEventListener('exit', function(event) {
        try {
            app.Log('exit function');            

            $('.ui-loader').hide();

        } catch (e) {
            app.ErrorLog(e);
        }
    });
}

此问题已在错误跟踪器上提出和讨论。 https://github.com/initialxy/cordova-plugin-themeablebrowser/issues/8

要点是你执行的脚本应该是

document.title

没有

return document.title