c#webbrowser中如何显示本地html中的图片

来源:百度知道 编辑:UC知道 时间:2024/06/28 14:43:49
1.c#webbrowser中如何显示本地html中的图片
2.如何点击webbrowser中的网页中的按钮,然后弹出winform窗体

请具体点.谢谢.

呵呵 ,看来您是个初学者。
1.webbrowser中显示本地图片只需调用navigate方法,比如:

this.webBrowser1.Navigate ("file:///C:\\WINDOWS\\Web\\Wallpaper\\Ascent.jpg");

2.webbrowser和程序通讯有N多方法,最简单的是地址拦住。webbrowser端通过脚本来实现location.href='xxx:abc',程序段通过拦住webbrowser的Navigating事件来完成的。简单例子:

1)创建一个html文件。
2)html内容为:

<html>
<body>
<input id=textbox> <input type=button onclick="if (textbox.value!="") location.href='abc:'+textbox.text;">
</body>
</html>

3)处理webbrowser的Navigating事件:

private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if (e.Url.ToString().Substring(0, 4) == "abc:")
{
e.Cancel = true;
Form fm = new Form();
fm.Text = e.Url.ToString().Substring(4);