请问这个错误怎么解决
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using mshtml;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
//getElementsByName,getElementById 这里也可以用这两个方法
IHTMLElementCollection els = doc.getElementsByTagName("a");
Point p = new Point();
foreach (IHTMLElement em in els)
{
if ((em.getAttribute("href").ToString() == "javascript:fGoto()") && (em.innerText == "添加附件"))
{
IHTMLElement pem = em;
//元素中间
p.X = em.offsetWidth / 2;
p.Y = em.offsetHeight / 2;
do
{
pem = pem.offsetParent;
p.X += pem.offsetLeft;
p.Y += pem.offsetTop;
} while (pem.tagName.ToLower() != "body");
em.scrollIntoView();//显示元素
break;
}
} }
}
}错误 1 “getAttribute”方法没有采用“1”个参数的重载 C:\Documents and Settings\Administrator\桌面\Test\WindowsApplication1\WindowsApplication1\Form1.cs 27 22 WindowsApplication1
错误 2 “scrollIntoView”方法没有采用“0”个参数的重载 C:\Documents and Settings\Administrator\桌面\Test\WindowsApplication1\WindowsApplication1\Form1.cs 39 21 WindowsApplication1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using mshtml;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
HTMLDocument doc = webBrowser1.Document.DomDocument as HTMLDocument;
//getElementsByName,getElementById 这里也可以用这两个方法
IHTMLElementCollection els = doc.getElementsByTagName("a");
Point p = new Point();
foreach (IHTMLElement em in els)
{
if ((em.getAttribute("href").ToString() == "javascript:fGoto()") && (em.innerText == "添加附件"))
{
IHTMLElement pem = em;
//元素中间
p.X = em.offsetWidth / 2;
p.Y = em.offsetHeight / 2;
do
{
pem = pem.offsetParent;
p.X += pem.offsetLeft;
p.Y += pem.offsetTop;
} while (pem.tagName.ToLower() != "body");
em.scrollIntoView();//显示元素
break;
}
} }
}
}错误 1 “getAttribute”方法没有采用“1”个参数的重载 C:\Documents and Settings\Administrator\桌面\Test\WindowsApplication1\WindowsApplication1\Form1.cs 27 22 WindowsApplication1
错误 2 “scrollIntoView”方法没有采用“0”个参数的重载 C:\Documents and Settings\Administrator\桌面\Test\WindowsApplication1\WindowsApplication1\Form1.cs 39 21 WindowsApplication1
/// 根据元素信息获取坐标
/// </summary>
/// <param name="Id">元素ID</param>
/// <param name="TextStr">元素内容 格式: input|登 录</param>
/// <returns></returns>
public Rectangle GetElementPointByMess(out IHTMLElement2 TempYs,string IdStr = "", string TextStr = "")
{
int YsX = -1;
if (BrowserH < 1)
{
BrowserH=Screen.PrimaryScreen.WorkingArea.Height - ((IHTMLElement2)Document.documentElement).clientHeight;
}
int YsY = BrowserH;
int YsWith = -1;
int YsHeight = -1;
//int dsadsa = ((IHTMLElement2)Document.documentElement).clientHeight;
TempYs = null;
try
{
if (IdStr != "")
{
IHTMLElement2 TempElement = ((IHTMLElement2)Document.getElementById(IdStr));
YsX = TempElement.getBoundingClientRect().left;
YsY += TempElement.getBoundingClientRect().top;
YsWith = TempElement.scrollWidth;
YsHeight = TempElement.scrollHeight;
TempYs = TempElement;
}
else if (TextStr != "")
{
IHTMLElement2 TempElement = null;
foreach (IHTMLElement i in Document.getElementsByTagName(TextStr.Split('|')[0].Trim()))
{
if (i.innerText == TextStr.Split('|')[1])
{
TempElement = (IHTMLElement2)i;
break;
}
}
YsX = TempElement.getBoundingClientRect().left;
YsY += TempElement.getBoundingClientRect().top;
YsWith = TempElement.scrollWidth;
YsHeight = TempElement.scrollHeight;
TempYs = TempElement;
}
}
catch
{
return new Rectangle(-1, -1, -1, -1);
}
return new Rectangle(YsX, YsY, YsWith, YsHeight);
}
/// <summary>
/// 元素操作
/// </summary>
/// <param name="ValueStr">值,当为"点击"则点击元素</param>
/// <param name="Ys">元素</param>
/// <returns></returns>
public bool SetElement(string ValueStr, IHTMLElement2 Ys)
{
try
{
if (ValueStr != "点击")
((IHTMLElement)Ys).setAttribute("value", ValueStr);
else
((IHTMLElement)Ys).click();
return true;
}
catch { return false; }
}我已经共享源码
http://bbs.csdn.net/topics/390401995