0

I am using the C# WebBrowser control. My HTML renders fine. However, I need to keep external files on the local computer. References to the local copy of files do not work.

How do I write the HTML to load locally stored files?

This works:

<script type='text/javascript' src='https://code.jquery.com/jquery-latest.min.js'></script>

This works when loading a file directly in to a browser, but not through the C# WebBrowser control:

<script type='text/javascript' src='./jquery-latest.min.js'></script>

Adding the full path gets rid of error messages, but still does not work.

<script type='text/javascript' src='file:///C:/<full path>/jquery-latest.min.js'></script>

I have tried adding this to the first line of the html file which does not solve the problem.

<!-- saved from url=(0014)about:internet -->

1 Answer 1

1

Just put your local js file in the same directory with your html file. Then use this will do

<script type='text/javascript' src='./jquery-latest.min.js'></script>
Sign up to request clarification or add additional context in comments.

2 Comments

Ok, I tried that before and it didn't work. Now that you posted this, it does :) Arghhh... Thanks!
Edited question to clarify issue. Not so fast. It works if I load the html file into a browser. But if I load the html file through the C# WebBrowser control, the external file is not loaded. It's a path issue. I specified the full path and still not working, ie: file:///c:/...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.