user3044482
user3044482

Reputation: 420

Interact with the DOM of a webview

All other chrome questions ask on how to edit the webview page and change things in it...

But I want to get an item from a webview and put it on to my app. For example if it were an i frame I would do something like this:

var iframe = (tabl.contentDocument) ? tabl.contentDocument : tabl.contentWindow.document;
document.getElementById("div1").innerHTML = iframe.getElementById("div2").innerHTML;

I want to pull information off of the webview for my own use, but every time I try I get the error because one frame is a chrome app and the other is https and its insecure or something

Upvotes: 0

Views: 1032

Answers (1)

Louis Haußknecht
Louis Haußknecht

Reputation: 924

You can inject javascript into the webview.

Something like this:

webview.executeScript({ code: "document.getElementById('myDomElement').innerHTML" }, function(result) {
        console.log(result);
    });

The callback returns the last evaluated value.

Upvotes: 3

Related Questions