fin*_*fin 0 javascript c# winforms
是否有可能举办和运行JavaScript高级,比如这个,直接在一个WinForms应用程序?为了超清楚,当我直接说,我的意思是我不能使用Web服务器来托管内容然后通过URL引用.我需要能够直接在表单上完成所有必需的功能.
你可以使用嵌入的html文件并将其加载到浏览器控件中吗?
示例HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
</title>
<script type="text/javascript">
alert("hello");
</script>
</head>
<body>
TESTING!
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我将此文件命名为alertTest.html.它的属性是:
Build Action: Content
Copy to Output Directory: Copy always
FileName: alertTest.html
Run Code Online (Sandbox Code Playgroud)
然后C#形式:
public Form1()
{
InitializeComponent();
StreamReader reader = new StreamReader("alertTest.html");
string html = reader.ReadToEnd();
this.webBrowser1.DocumentText = html;
}
Run Code Online (Sandbox Code Playgroud)
这将生成一个警告框和单词TESTING!在窗体上.
| 归档时间: |
|
| 查看次数: |
871 次 |
| 最近记录: |