作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 dcef3 在我的 Delphi 应用程序中嵌入浏览器。我想启用远程调试,以便检查嵌入式浏览器中运行的 JavaScript 代码。
当显示包含 TChromium 控件的父窗体时,我尝试启用远程调试端口,但我不确定如何继续实际访问调试器:
procedure TMapViewSingleSector.FormShow(Sender: TObject);
begin
CefRemoteDebuggingPort := 9000;
ChromeView.Load('http://localhost:8080/');
end;
但是,当我尝试从另一个 Chrome 浏览器访问 localhost:9000 时,页面无法加载。
编辑:我将 CefRemoteDebuggingPort
初始化移至表单初始化部分(在表单显示之前)。现在,当我将 google chrome 指向端口 9000 时,我可以看到 Web 组件。但是我还有另一个错误:
inspector.js:10392 Uncaught TypeError: Object.observe is not a function
at WebInspector.Main._createSettings (inspector.js:10392)
at WebInspector.Main._gotPreferences (inspector.js:10384)
at WebInspector.InspectorFrontendHostStub.getPreferences (inspector.js:1352)
at WebInspector.Main._loaded (inspector.js:10383)
at windowLoaded (inspector.js:677)
注意:我的chrome浏览器版本与DCEF3不一样。
最佳答案
我只需从代码中打开开发人员工具控制台。有ShowDevTools方法来做到这一点。为此,您可以使用专用按钮或例如在 HTML 页面和 OnBeforeBrowse 中创建虚假链接事件取消导航并显示控制台。例如,当有这个假链接时:
<html>
<body>
<a href="ShowDevTools.fake">Show console</a>
</body>
</html>
您可以在应用程序中编写类似的内容:
procedure TForm1.Chromium1BeforeBrowse(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; isRedirect: Boolean; out Result: Boolean);
const
UrlShowDevTools = 'ShowDevTools.fake';
begin
{ if the user clicked link and URL equals to the fake one }
if (Request.TransitionType = TT_LINK) and (Request.Url = UrlShowDevTools) then
begin
{ cancel navigation }
Result := True;
{ show the developer tools console }
TChromium(Sender).ShowDevTools;
end;
end;
关于delphi - 如何使用 dcef3 启用远程调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44521330/
我已经使用最新的 Delphi Chromium Embedded 包装器(使用 libcef 3.1750.1738,我相信是由 DCEF3 创建者编译的)在 Delphi 2007 中实现了 Ge
我是一名优秀的程序员,十分优秀!