代码如下 为什么webbrowser.document为空? 如何解决?webbrowser.url=new Uri("http://localhost/www/test.htm");
webbrowser.show();
webbrowser.document.invokescript("getInfo");
webbrowser.show();
webbrowser.document.invokescript("getInfo");
解决方案 »
- 求助一个c++ 调用C#的多个.cs类的问题,多谢!
- 当窗体程序在任务栏没有图标(用this.hide()或this.ShowInTaskBar=false隐藏后,只有右下角的托盘中有),第二次启动不能激活该窗体?
- web页面关闭按钮的控制问题
- 程序运行到“cn.open();” 就报错了
- 怎样将用户控件拖到另一个设计窗体?
- 怎样设置dataset里面datatable某一字段的默认值?
- 局域网内从一台机器copy文件到另外一台机器,有什么方法获得copy的进度?
- 用csc生成dll时报错
- 窗口resize的问题
- 请问有没有C#版的Pop3邮件代理程序?
- 有这样一个功能,是否可以实现
- 如何获得一段字符串里的所有网址及邮箱地址?
也就是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();
} }