TWebBrowser不显示我的网站

时间:2015-08-12 10:24:35

标签: jquery angularjs delphi twebbrowser

我想使用组件TWebBrowser将我的web项目加载到我的delphi应用程序中。我的项目基于angular tree grid,适用于包括IE在内的所有浏览器。当我将Web项目加载到Delphi XE8项目并运行应用程序时,突然出现了一些错误,所以我在StackOverflow上搜索了this。其他页面的一些“技巧”也没有帮助。我加载了angularJS插件的基本示例,找到here(只是为了确定,这不是我的代码错误)。

我在Delphi中使用的代码是:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
 WebBrowser1.Navigate('file://C:\Users\Peter\Documents\Embarcadero\Studio\Projects\Win32\Debug\index.html');
end;

end.
编辑:此Delphi代码仅导航到我的PC上的index.html。 index.html与here相同。是的,所有其他文件都已正确设置。 index.html适用于其他浏览器。

问题:如何解决Delphi的问题

更新(解决方案): 因为问题被标记为重复,因为找到了here的解决方案,所以在我的情况下它不起作用......正如我所希望的那样。是的,它适用于插件的演示示例(因为它包含来自web的脚本,我的是LOCALLY)。

经过几个小时的工作,我在MS论坛上找到了解决方案。

  1. 我建议您验证Javascript代码 - 在我的情况下,我没有在脚本标签
  2. 中包含类似type =“text / javascript”的属性
  3. 接下来,我在MS论坛上找到的解决方案是他们包含脚本的方式:
    • 脚本的示例包括:<script type="text/javascript" src="file://127.0.0.1/c$/<MY_PATH_TO_FILE>.js"></script>
  4. 最后,感谢用户whosrdaddy提到solved case
    • 所以我必须添加<meta http-equiv="X-UA-Compatible" content="IE=edge" />
  5. 我希望这对某人有用..

    enter image description here

0 个答案:

没有答案
相关问题