3

I want to load my web project into my delphi app, using the component TWebBrowser. My project bases on angular tree grid and works on all browsers including IE. When I loaded the web project into Delphi XE8 project and ran the app, suddenly some error appeared, so I searched on StackOverflow, found this. Also some 'tricks' from other pages didnt help. I loaded the basic example of the angularJS plugin, found here (just to be sure, it isn't my codes fault).

The code I used in Delphi is:

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.

EDIT: This Delphi code only navigates to the index.html on my PC. The index.html is the same as here . And yes, all other files are correctly set. The index.html works in other browsers.

QUESTION: How to fix this for Delphi

UPDATE (SOLUTION): As the question was marked as a duplicate because the solution was found here, it didn't work in my case ...as I wanted. Yes, it worked for the demo example of plugin (because it included scripts from web, mine was LOCALLY).

After hours of working on the case, I've found a solution on a MS forum.

  1. I suggest you to validate the Javascript code -in my case i didn't include atributes like type="text/javascript" to the script tag
  2. As next, the solution I found on MS forum was the way they included the script:
    • an example of a script include is: <script type="text/javascript" src="file://127.0.0.1/c$/<MY_PATH_TO_FILE>.js"></script>
  3. And finally, thanks to user whosrdaddy for mentioning a solved case
    • So I had to add <meta http-equiv="X-UA-Compatible" content="IE=edge" />

I hope that this will work for someone..

enter image description here

Community
  • 1
  • 1
Peter
  • 1,589
  • 2
  • 20
  • 27
  • And relation with jQuery ? – ebilgin Aug 12 '15 at 10:26
  • This is the Delphi code which Navigates to index.html which is totally the same as the plugin uses http://khan4019.github.io/tree-grid-directive/test/treeGrid.html – Peter Aug 12 '15 at 10:27
  • you must modify the registry to set your webbrowser in IE-EDGE mode, standard, it renders the page in IE7 mode. You can simulate this by pressing F12 in IE and use IE7 in the emulation tab, you will see the same problem. Delphi's TWebbrowser is nothing but a wrapper for Microsofts' axwebbrowser control. Anyway you can find the correct answer [here](http://stackoverflow.com/a/5357205/800214) – whosrdaddy Aug 12 '15 at 13:12
  • Thank you for your correction. I tried the solution you mentioned but it didn't work at all (worked on the base plugin). So I continued to searching for a solution. I found a trick for IE for including scripts: .. And that worked for me. I appreciate that you followed the rules and marked it as a duplicate. But I hope my solution helps someone with the same problem. – Peter Aug 13 '15 at 06:17
  • 1
    It stays a dupe, add the registry key or adding the meta tag (only possible if you have control over the content) is the correct solution for your problem. – whosrdaddy Aug 14 '15 at 09:08

0 Answers0