如何从JScript / VBScript调用系统代码?

时间:2021-04-14 07:28:09

I have a C# app that uses a web browser control to display some HTML and do some JScript in the background.

我有一个C#应用程序,它使用Web浏览器控件来显示一些HTML并在后台执行一些JScript。

How do I integrate this with other system calls? Do I call other C# code from JScript/VBScript? Do I need to do it from the form itself?

如何将其与其他系统调用集成?我是否从JScript / VBScript调用其他C#代码?我需要从表单本身做到吗?

1 个解决方案

#1


When I need javascript hosted in a webbrowser control to call back to the parent, I have it try to navigate the page to another URL. Then in the webbrowser's "BeforeNavigate" event, I get the URL the page was trying to go to, parse out any arguments, dispatch the request to the other C# code, then cancel the original navigate request.

当我需要在webbrowser控件中托管的javascript来回调父级时,我尝试将页面导航到另一个URL。然后在webbrowser的“BeforeNavigate”事件中,我获取页面试图访问的URL,解析出任何参数,将请求分派给其他C#代码,然后取消原始导航请求。

#1


When I need javascript hosted in a webbrowser control to call back to the parent, I have it try to navigate the page to another URL. Then in the webbrowser's "BeforeNavigate" event, I get the URL the page was trying to go to, parse out any arguments, dispatch the request to the other C# code, then cancel the original navigate request.

当我需要在webbrowser控件中托管的javascript来回调父级时,我尝试将页面导航到另一个URL。然后在webbrowser的“BeforeNavigate”事件中,我获取页面试图访问的URL,解析出任何参数,将请求分派给其他C#代码,然后取消原始导航请求。