How To Get HTML Element Dimensions From JS To C++ Variables

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.

How To Get HTML Element Dimensions From JS To C++ Variables

Postby TahriT » Wed Nov 29, 2017 3:44 am

Hello CEF Community,

I have a goal to get the elements of a webpage using Javascript in to C++ variables. I've read the best method of working with the DOM is JS.
However I little experience with JS and the v8 contexts in CEF. Any suggestions on an approach are appreciated. The setup I have now is similar to below:

Code: Select all
struct element
{
   int width ;
   int length;
   int x; // top left
   int y; // top left
};
std::stack<element> elements ;


Code: Select all
for (int x = 0; domElements.getLength(); x++)
{
element div;
div.width  =  var.width() // What I need help on
div.length  = var.height()
div ...etc.
elements.push(div);
}


From here I would like to put the element dimensions returned from JS into the C++ element object. Or by some other method return a JS object that can be used by C++ methods.
I've read through https://bitbucket.org/chromiumembedded/ ... ntegration
But its still unclear to me on exactly what my approach should be. I'm a beginner on the JS side of things and CEF I'm just breaking into.

Any help on this would be greatly appreciated! Thanks in advance!
TahriT
Newbie
 
Posts: 1
Joined: Wed Nov 29, 2017 3:13 am

Re: How To Get HTML Element Dimensions From JS To C++ Variab

Postby magreenblatt » Wed Nov 29, 2017 9:59 am

Here's a complete example of how to define a JS binding function and handle the callback in C++: https://bitbucket.org/chromiumembedded/ ... ?at=master
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], yutou15 and 33 guests