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

拟墨画扇 提交于 2019-12-24 07:38:06

问题


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?


回答1:


Try this:

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


来源:https://stackoverflow.com/questions/42503265/how-can-i-support-window-external-xxx-in-cef-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!