magreenblatt wrote:It depends on the content. Using ExecuteJavaScript will work, but you need to have correct JavaScript. You can use the DevTools console to try JavaScript snippets and find what works.
This is what I came up with (with no success modifying original HTML content though). Following JS creates a simple div, adds an img tag to it, updates dom with the new div. Finally JS is called OnLoadEnd event.
- Code: Select all
void SimpleHandler::UpdateDOM(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame)
{
std::string code = "var div = document.createElement('div');";
code += "div.id = 'pageHeader';";
code += "var img = document.createElement('img');";
code += "img.src = 'some_local_path\\logo.jpg';";
code += "img.width = 250;";
code += "img.height = 250";
code += "div.appendChild(img)";
code += "document.body.appendChild(div);";
frame->ExecuteJavaScript(code, frame->GetURL(), 0);
}
void SimpleHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode)
{
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
CefPostTask(TID_UI,
base::Bind(&SimpleHandler::UpdateDOM, this, browser, frame));
return;
}
setTimeOut(browser, frame, _pdffile, _instructions);
}
Am I missing something obvious?
Thanks!