[英]Apache Cordova access HTML of iframe
有沒有辦法在Apache Cordova中獲取iframe的innerHTML? 目前,我有以下代碼是對onDeviceReady函數的修改
onDeviceReady: function() {
this.receivedEvent('deviceready');
var iframe = cordova.InAppBrowser.open("http://example.com");
alert(iframe.document.body.innerHTML);
},
這不會發出任何警報。
我嘗試過直接在HTML中創建iframe,但是src永遠不會加載,並且始終保持空白。 我嘗試安裝白名單插件,並在config.xml中添加了
<allow-navigation href="*" />
但這什么也沒做。
cordova.InAppBrowser.open
不返回iframe引用,因為InappBrowser不使用iframe,它使用本機Webview實例加載和顯示HTML內容。
您將需要使用executeScript()來動態修改InappBrowser實例的加載內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.