Tony Teng
Tony Teng

Reputation: 125

How can I support window.external.xxx in cef framework

I want to switch from an embedded IE activeX to the libcef framework. My web project's javascript call C++ function use window.external.xxx method. But I can't get window.external object in cef framework. I try to bind my c++ function in window object. sadly, it doesn't work for me.

My code for binding c++ function to window object is like that:

CefRefPtr<CefV8Value> ptrGlobalObj = context->GetGlobal();
CefRefPtr<CefV8Value> jsCallOrthoLink = CefV8Value::CreateFunction(_T("CallOrthoLink"), m_ptrV8Handler);
ptrGlobalObj->SetValue(_T("CallOrthoLink"), jsCallOrthoLink, V8_PROPERTY_ATTRIBUTE_NONE);

I test it with window.xxx method in javascript. it works. so I know my bind codes are correctly.

How can I fixed this issue with window.external.xxxx method?

Upvotes: 1

Views: 1452

Answers (1)

Czarek Tomczak
Czarek Tomczak

Reputation: 20645

Try this:

external = CefV8Value::CreateObject(NULL, NULL)
external->SetValue("CallOrthoLink", jsCallOrthoLink, V8_PROPERTY_ATTRIBUTE_NONE)
global->SetValue("external", external, V8_PROPERTY_ATTRIBUTE_NONE)

Upvotes: 2

Related Questions