//如何得到选中的图片的地址
using mshtml;
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(@"D:AdministratorDesktop123.htm");
webBrowser1.Document.ExecCommand("EditMode", false, null);
} IHTMLDocument2 doc = (IHTMLDocument2)webBrowser1.Document.DomDocument;
if (doc.selection.type == "Control")
{
IHTMLControlRange controlRange = (IHTMLControlRange)doc.selection.createRange();
IHTMLImgElement imgTag = (IHTMLImgElement)controlRange.item(0);
//return file:///D:/Administrator/Desktop/123_files/143645546.jpg
textBox1.Text = imgTag.src;
}05.6 获取webBrowser1中所有的图片地址
private void button1_Click(object sender, EventArgs e)
{
HtmlElementCollection imgs = webBrowser1.Document.Images;
for (int i = 0; i < imgs.Count; i++)
{
textBox1.AppendText(imgs[i].GetAttribute("src") + "
");
}
}