Simple way to access dom html content

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Simple way to access dom html content

Postby silver » Sat Apr 11, 2015 11:14 pm

Hi

How do I access html contents of dom elements from the browser process ?
like >> document.getElementById("something").innerHTML ?
User avatar
silver
Techie
 
Posts: 48
Joined: Tue Feb 24, 2015 5:39 am

Re: Simple way to access dom html content

Postby magreenblatt » Mon Apr 13, 2015 4:09 am

magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Simple way to access dom html content

Postby silver » Tue Apr 14, 2015 1:58 am



yes, read that quite a few times. The page mentions about "pushing" things into the javascript context from application.

My application needs to pull out the javascript values/output from the page.

Like ...

Code: Select all
std::string html = Object->SomeCEFfunctionToGetHtml();
process(html);


How ?
User avatar
silver
Techie
 
Posts: 48
Joined: Tue Feb 24, 2015 5:39 am

Re: Simple way to access dom html content

Postby magreenblatt » Tue Apr 14, 2015 3:34 am

You have a few options:

1. Create a bound V8 function in the renderer process. Send an IPC message to the browser process.
2. Implement a custom scheme handler or GetResourceHandler in the browser process. Send an XMLHttpRequest to the browser process.

These can also be combined in various permutations.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Simple way to access dom html content

Postby silver » Wed Apr 15, 2015 10:16 pm

magreenblatt wrote:You have a few options:

1. Create a bound V8 function in the renderer process. Send an IPC message to the browser process.
2. Implement a custom scheme handler or GetResourceHandler in the browser process. Send an XMLHttpRequest to the browser process.

These can also be combined in various permutations.


I guess, both the above options are "asynchronous".
Is there any way to implement a synchronous function to "call and get" the html right at one place.
User avatar
silver
Techie
 
Posts: 48
Joined: Tue Feb 24, 2015 5:39 am

Re: Simple way to access dom html content

Postby magreenblatt » Thu Apr 16, 2015 4:12 am

silver wrote:Is there any way to implement a synchronous function to "call and get" the html right at one place.

You could use a synchronous XMLHttpRequest but it is not recommended.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Simple way to access dom html content

Postby silver » Sat Apr 18, 2015 9:34 am

If i implement a custom scheme handler and make an xhr request on the webpage to this custom scheme,
Won't the browser security block such requests ?
User avatar
silver
Techie
 
Posts: 48
Joined: Tue Feb 24, 2015 5:39 am

Re: Simple way to access dom html content

Postby magreenblatt » Sun Apr 19, 2015 9:55 am

silver wrote:If i implement a custom scheme handler and make an xhr request on the webpage to this custom scheme,
Won't the browser security block such requests ?

Maybe. It depends on the source and target origin, CSP headers, etc.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 36 guests

cron