gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 16:18:27 25 4
gpt4 key购买 nike

嗨,我正在使用 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

关于javascript - 在 themeablebrowser Cordova/Phonegap 中获取页面标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29366485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com