0

It seems when i use TEdgeBrowser and navigate to my html file, that loading external local javascript files in that html does not work. -nothing happens

for example i have in html:

<!DOCTYPE>
<html>
    <head>
        
    </head>
    <body>
        <script src="test.js"></script>
    </body>
</html>

And javascript file:

alert('HELLO');

It is simple example that should message me HELLO, but doesn't matter what is in javascript, it just doesn't load.

I don't get any DevTools errors.

When i run the html in normal browser for example chrome or edge on my pc, it works fine. Also, when i have a script that is not local, but remote, then it works too. So it seems that the problem is only with local files. (I run delphi as administrator).

What could be the problem? I have delphi 10.4.2

  • This is impossible: either you want to include files via `` or you have to write proper JS within the element via ``. Edit your question to include a full HTML file and its JS file which in your opinion works for (external) web browsers, but not with a Delphi component. – AmigoJack Jan 19 '23 at 13:46
  • I am sorry. I wrote the code with head and script wrong.. It is right now. – Pavel Vlasák Jan 19 '23 at 14:27
  • Do you have the same problem if you load the HTML file into the actual Edge browser? If so, then you can use its debugger to find out why the script is failing. Searching around, I see one possibility is that Edge may actually be loading the script and then immediately unloading it if it contains problems that Edge doesn't like. – Remy Lebeau Jan 19 '23 at 15:58
  • 1
    I repeat: give both files in full (not just parts of it) but minimal (without unneeded details) which reproduce your problem. If you do that you can also check for yourself if the problem persists, or if it really seems to have a different culprit. – AmigoJack Jan 19 '23 at 16:23
  • 1
    Check for any errors listed in DevTools. There are some security limitations of what the file: URI scheme allows, although it should match what the browser does with local files. If that is the issue you should check out CoreWebView2.SetVirtualHostNameToFolderMapping to map your local files on to a virtual https://app.example host. – David Risney Jan 19 '23 at 19:14

0 Answers0