我正在使用 InAppBrowser 加载外部页面,但 Android 上似乎 loadstart 和 loadstop 都没有被触发。我的代码:
var ref = window.open(url, '_blank', 'location=yes;');
ref.addEventListener('loadstart', function() {
console.log('loadstart!');
console.log(event.url);
});
最佳答案
一些检查应该可以解决这个问题。
确保加载正确的 cordova-2.x.x.js 文件
// Platform: android
在 res/xml/config.xml 中包含 InAppBrowser 插件
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
编写正确的白名单标签(与 iOS 不同)
<access origin="https://domain.com" subdomains="true" />
您确实必须像示例文件中那样包含 onDeviceReady,这对我来说很有效。
document.addEventListener('deviceready', app.onDeviceReady, false);
关于sencha-touch - Android InAppBrowser 事件在phonegap-build 中未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16865723/