i have a problem communicating between javascript and CEF. What I do is the following:
Code: Select all
window.signalCef = function(command) {
window._HBBTV_DEBUG_ && console.log("signalCef(" + command + ")");
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "jsevent://" + command);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
};
Code: Select all
procedure TfrmMain.DoChromiumOnBeforeResourceLoad(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const callback: ICefRequestCallback;
out Result: TCefReturnValue);
var
url: string;
begin
url := request.getUrl;
if pos('jsevent://', url) > 0 then
begin
EvaluateCommand(Copy(url, pos('://', url) + 3, length(url)));
Result := RV_CANCEL;
end;
end;
Does someone has a better idea how to interact with the main application from javascript?