2、填写CoClass Name,选择Apartment、Internal
3、添加扩展方法,如 doAction方法
4、添加WebBrowser方法
procedure TfMain2.WBGetExternal(Sender:TCustomEmbeddedWB; var ppDispatch: IDispatch);var WBExt: TWBExt;begin inherited; WBExt:= TWBExt.Create; //创建实现自动化接口的对象 ppDispatch :=WBExt; //将对象接口传递给WebBrowserControlend;5、JS中调用
function doAction(sAction){ if (!window.external) return; if (typeof(window.external.doAction)=='undefined') return; return window.external.doAction(sAction);}
- 热点聚合:WebBrowser 扩展 接口 添加 Delphi