webbrowser.document为空? 代码如下 为什么webbrowser.document为空? 如何解决?webbrowser.url=new Uri("http://localhost/www/test.htm");webbrowser.show();webbrowser.document.invokescript("getInfo"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不要在load事件里写webbrowser.document.invokescript("getInfo"); 也就是webbrowser.show()以后不能立即执行webbrowser.document.invokescript("getInfo")? 在WinForm下用这个控件会比较好!其它的地方都有或多或少的问题存在,我遇见过! 写到DocumentCompleted里就行了,LOAD的时候WEBBROWER还没加载完HTML 写发不对吧。你要完成功能是什么那? 参考我的代码 private void button1_Click(object sender, EventArgs e) { object Zero = 0; object EmptyString = ""; axWebBrowser1.Navigate(textBox1.Text, ref Zero, ref EmptyString, ref EmptyString, ref EmptyString); } private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { IHTMLDocument2 HTMLDocument = (IHTMLDocument2)axWebBrowser1.Document; IHTMLElementCollection links = HTMLDocument.links; listBox1.Items.Clear(); string uspath = Application.StartupPath + "\\WriteLines.html"; uspath.Remove(0); //using ( StreamWriter sw = new StreamWriter(@"C:\WriteLines.html", true)) using (StreamWriter sw = new StreamWriter(uspath, true)) foreach (HTMLAnchorElementClass el in links) { listBox1.Items.Add(el.outerHTML); //sw.Close(); } } 关于winform窗体重绘图形闪烁的问题 C# 给word文档添加目录 有关跨线程访问控件的一个疑难问题。 手机发短信催报功能 WINFORM--如何把一个girdview中的一行添加到另一个gridview?两个gridview列一样 怎么获取本地磁盘文件目录列表啊? 应该是.net代码编辑器的问题!具体请进来看!不知你们有没有碰到过?有没有办法解决? 自定义控件使用的问题 wj,进来拿分~~~~~~~~~~````````` C# 里用 API 太痛苦了。 有这样一个功能,是否可以实现 如何获得一段字符串里的所有网址及邮箱地址?
也就是webbrowser.show()以后不能立即执行webbrowser.document.invokescript("getInfo")?
private void button1_Click(object sender, EventArgs e)
{
object Zero = 0;
object EmptyString = "";
axWebBrowser1.Navigate(textBox1.Text, ref Zero, ref EmptyString, ref EmptyString, ref EmptyString);
} private void axWebBrowser1_DocumentComplete(object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
IHTMLDocument2 HTMLDocument = (IHTMLDocument2)axWebBrowser1.Document;
IHTMLElementCollection links = HTMLDocument.links; listBox1.Items.Clear();
string uspath = Application.StartupPath + "\\WriteLines.html";
uspath.Remove(0);
//using ( StreamWriter sw = new StreamWriter(@"C:\WriteLines.html", true))
using (StreamWriter sw = new StreamWriter(uspath, true))
foreach (HTMLAnchorElementClass el in links)
{
listBox1.Items.Add(el.outerHTML);
//sw.Close();
} }