[英]Cordova inappbrowser: executeScript on loadstart
Is it possible to executeScript() on loadstart event in Cordova inAppBrowser? 是否可以在Cordova inAppBrowser中的loadstart事件上执行executeScript()? Here is my standalone example I made to try to make it happen: 这是我尝试实现的独立示例:
<!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>
Doesn't work for me though. 虽然对我不起作用。 Config.xml allow origin is set to *. Config.xml的允许来源设置为*。 Any suggestions? 有什么建议么?
Thanks! 谢谢!
Yes, it possible to executeScript() on loadstart.Remove {} from alert part as follows: 是的,可以在loadstart.executeScript()上从警报部分删除{},如下所示:
function testFunction() {
iabRef.executeScript({
code: 'alert("It is alive! ALIVE!");'
});
}
Hope this works 希望这行得通
After a little bit of wandering I found that changing "_self" to "_blank" makes it work. 徘徊了一点之后,我发现将“ _self”更改为“ _blank”可以使它工作。 So: 所以:
iabRef = window.open('http://telegraph.co.uk', '_blank', 'location=no', 'zoom=no', 'hardwareback=yes');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.