是否可以在Cordova inAppBrowser中的loadstart事件上执行Script()?这是我试图实现它的独立示例:
<!DOCTYPE html>
<html>
<head>
<title>Standalone Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
var iabRef = null;
function testFunction() {
iabRef.executeScript({
code: {'alert("It is alive! ALIVE!")'}
});
}
function onDeviceReady() {
iabRef = window.open('http://telegraph.co.uk', '_self', 'location=no', 'zoom=no', 'hardwareback=yes');
iabRef.addEventListener('loadstart', testFunction);
}
</script>
</head>
<body>
</body>
</html>
虽然不适合我。 Config.xml允许origin设置为*。有什么建议吗?
谢谢!
答案 0 :(得分:0)
是的,可以在来自警报部分的loadstart.Remove {}上执行Script(),如下所示:
function testFunction() {
iabRef.executeScript({
code: 'alert("It is alive! ALIVE!");'
});
}
希望这有效
答案 1 :(得分:0)
经过一番徘徊后,我发现改变了自己&#34; _self&#34;到&#34; _blank&#34;使它工作。所以:
iabRef = window.open('http://telegraph.co.uk', '_blank', 'location=no', 'zoom=no', 'hardwareback=yes');