I hope you are all doing well.
I want to calculate positions of 'child frames' inside the 'main frame'.
I did the following.
- Code: Select all
CefRefPtr<CefFrame> mainframe = m_cefBrowser->GetMainFrame();
CString js;
js.Format(
L"var i, iframes = document.getElementsByTagName('iframe')"
L"for(i = 0; i < iframes.length; i++){"
L" console.log(JSON.stringify(iframes[i].getBoundingClientRect()));"
L"}"
);
mainframe->ExecuteJavaScript(js.GetString(), frame->GetURL(), 0);
Then I needed to identify which iframe element is assigned to which CefFrame.
I tried to compare iframe's src and name attribute values with CefFrame::GetURL and CefFrame::GetName.
In this way, I could calculate the position, width, and height of each CefFrame.
My problem is when the iframe element hasn't got src or name attribute, how can I get the position of the corresponding CefFrame?
Is there any direct way of doing this?
CefFrame class can't return attribute values except src and name?
Maybe CefFrame::GetIdentifier() increases in order of element array document.getElementsByTagName('iframe') ?
Thanks for your attention.