Hi i'am working in Cordova v3.7 and themeablebrowser Cordova plugin in want to get title of the page in themeablebrowser i can't get it. I have tried executeScript as specified in documentation but app crashes. here's what i have done so far.
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);
}
});
}
This question has been raised and discussed on bug tracker. https://github.com/initialxy/cordova-plugin-themeablebrowser/issues/8
The gist is that the script you execute should be
document.title
Not
return document.title