hello,
i have a little js binding problem and hope that anyone here can help me. i am new to cef and my js knowledge is beginner level. here is my code with comments that show what i like to achieve:
// Render process:
void OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) OVERRIDE {
message_router_->OnContextCreated(browser, frame, context);
CefRefPtr<CefV8Value> object = context->GetGlobal();
CefRefPtr<CefV8Value> str = CefV8Value::CreateString("default testvalue");
object->SetValue("myevent", str, V8_PROPERTY_ATTRIBUTE_NONE);
// define an eventlistener for window.postmessage that is sent when
// the user on the website enters text andclicks a button
// this works as far as i see correctly. The listener is triggered when the user click the button
/ and the entered text is shown correctly in the alert box
CefString jscode = "window.addEventListener('message'"
", function(event) {"
"window.myevent = event.data.eventType;"
"alert(window.myevent);}, false);";
frame->ExecuteJavaScript(jscode, frame->GetURL(), 0);
CefString val = object->GetValue("myevent")->GetStringValue();
// when i test that value i see that the default value has not changed.
}
}Can anybody tell me what i am doing wrong?
thanks a lot,
Georg