C#WebBrowser不加载本地JavaScript文件
我正在使用C#WebBrowser控件。我的HTML使得很好。但是,我需要将外部文件保留在本地计算机上。引用文件本地副本不起作用。
如何编写HTML以加载本地存储的文件?
这起作用:
<script type='text/javascript' src='https://code.jquery.com/jquery-latest.min.js'></script>
当将文件直接加载到浏览器中时,这起作用了,但不能通过C#WebBrowser控件:
<script type='text/javascript' src='./jquery-latest.min.js'></script>
添加完整路径可以摆脱错误消息,但仍然不起作用。
<script type='text/javascript' src='file:///C:/<full path>/jquery-latest.min.js'></script>
我尝试将其添加到HTML文件的第一行中,该文件无法解决问题。
<!-- saved from url=(0014)about:internet -->
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 -->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将您的本地JS文件与HTML文件放在同一目录中。然后使用此操作
Just put your local js file in the same directory with your html file. Then use this will do