HREF和AXwebbrowser [英] A HREF and AXwebbrowser
问题描述
您好,
有人知道如何模拟< A HAREF>上的点击标签?
THX
Nico
Hello,
Somebody knows how i can simulate a click on a <A HAREF> tag ?
THX
Nico
推荐答案
nicolas写道:
nicolas wrote:
有人知道如何模拟< A HAREF>上的点击标签?
Somebody knows how i can simulate a click on a <A HAREF> tag ?
您好Nicolas,
//添加对MSHTML对象库的引用
>
[...]
public Form1()
{
InitializeComponent();
//等到文档加载完毕后
axWebBrowser1.DocumentComplete + =
新AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent处理程序(
axWebBrowser1_DocumentComplete);
}
private void button1_Click(object sender,System.EventArgs e)
{
// C#无法处理可选参数
object miss = Type.Missing;
// goto google.com
axWebBrowser1.Navigate(
" http://www.google.com" ;, ref miss,ref miss,ref miss,ref miss);
}
//
private void axWebBrowser1_DocumentComplete(
对象发送者,AxSHDocVw.DWebBrowserEvents2_Docum entCompleteEvent e)
{
//获取对HTML文档的引用
mshtml.HTMLDocumentClass doc =
(mshtml.HTMLDocumentClass)axWebBrowser1.Document;
// HTML文档中的foreach链接
foreach(doc.links中的mshtml.HTMLAnchorElementClass链接)
{
if(link.href ==" http://www.google.de/grphp?hl = de& tab = wg")
{
//执行Google-Groups-Link上的点击
link.click();
} < br $>
}
}
干杯
Arne Janning
Hi Nicolas,
//add a reference to the MSHTML Object Library
[...]
public Form1()
{
InitializeComponent();
// Wait until the document has finished loading
axWebBrowser1.DocumentComplete +=
new AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent Handler(
axWebBrowser1_DocumentComplete);
}
private void button1_Click(object sender, System.EventArgs e)
{
//C# cannot deal with optional params
object miss = Type.Missing;
//goto google.com
axWebBrowser1.Navigate(
"http://www.google.com", ref miss, ref miss, ref miss, ref miss);
}
//is called when the browser has finished loading the page
private void axWebBrowser1_DocumentComplete(
object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
//get a reference to the HTML-document
mshtml.HTMLDocumentClass doc =
(mshtml.HTMLDocumentClass) axWebBrowser1.Document;
//foreach link in the HTML-document
foreach (mshtml.HTMLAnchorElementClass link in doc.links)
{
if (link.href == "http://www.google.de/grphp?hl=de&tab=wg")
{
//perform the click on the Google-Groups-Link
link.click();
}
}
}
Cheers
Arne Janning
谢谢Arne,我会试一试。
Arne Janning < SP ***************** @ msn.com>一个écritdansle message de
新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ...
thanks Arne, i will try it.
"Arne Janning" <sp*****************@msn.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP11.phx.gbl...
nicolas写道:
nicolas wrote:
有人知道如何模拟< A HAREF>上的点击标签?
Somebody knows how i can simulate a click on a <A HAREF> tag ?
你好Nicolas,
//添加对MSHTML对象库的引用
[...]
public Form1()
{InitialifyComponent();
//等到文档加载完毕后
axWebBrowser1.DocumentComplete + = <新的AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent处理程序(
axWebBrowser1_DocumentComplete);
}
私有void button1_Click(对象发送者,System.EventArgs e)
{
// C#无法处理可选参数
对象未命中= Type.Missing;
//转到google.com
axWebBrowser1.Navigate(
" http://www.google当浏览器加载完页面时调用。
private void axWebBrowser1_DocumentComplete(.com",ref miss,ref miss,ref miss,ref miss);
//
对象发送者,AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
//
//获取对HTML文档的引用
mshtml.HTMLDocumentClass doc =
(mshtml.HTMLDocumentClass)axWebBrowser1.Document;
// HTML文档中的foreach链接
foreach(doc中的mshtml.HTMLAnchorElementClass链接)。链接)
{
if(link.href ==" http://www.google.de/grphp?hl = de& tab = wg")
//执行Google-Groups-Link上的点击
link.click();
}
}
干杯
Arne Janning
Hi Nicolas,
//add a reference to the MSHTML Object Library
[...]
public Form1()
{
InitializeComponent();
// Wait until the document has finished loading
axWebBrowser1.DocumentComplete +=
new AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent Handler(
axWebBrowser1_DocumentComplete);
}
private void button1_Click(object sender, System.EventArgs e)
{
//C# cannot deal with optional params
object miss = Type.Missing;
//goto google.com
axWebBrowser1.Navigate(
"http://www.google.com", ref miss, ref miss, ref miss, ref miss);
}
//is called when the browser has finished loading the page
private void axWebBrowser1_DocumentComplete(
object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
//get a reference to the HTML-document
mshtml.HTMLDocumentClass doc =
(mshtml.HTMLDocumentClass) axWebBrowser1.Document;
//foreach link in the HTML-document
foreach (mshtml.HTMLAnchorElementClass link in doc.links)
{
if (link.href == "http://www.google.de/grphp?hl=de&tab=wg")
{
//perform the click on the Google-Groups-Link
link.click();
}
}
}
Cheers
Arne Janning
它正在运作...... thx
" nicolas" < NI ********** @ laposte.net>一个écritdansle message de
新闻:%2 *************** @ TK2MSFTNGP11.phx.gbl ...
It''s working ... thx
"nicolas" <ni**********@laposte.net> a écrit dans le message de
news:%2***************@TK2MSFTNGP11.phx.gbl...
谢谢Arne,我会试一试。
Arne Janning < SP ***************** @ msn.com> écritdansle message de
新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ...
thanks Arne, i will try it.
"Arne Janning" <sp*****************@msn.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP11.phx.gbl...
nicolas写道:
nicolas wrote:
有人知道如何模拟< A HAREF>上的点击标签?
Somebody knows how i can simulate a click on a <A HAREF> tag ?
你好Nicolas,
//添加对MSHTML对象库的引用
[...]
public Form1()
{InitialifyComponent();
//等到文档加载完毕后
axWebBrowser1.DocumentComplete + = <新的AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent处理程序(
axWebBrowser1_DocumentComplete);
}
私有void button1_Click(对象发送者,System.EventArgs e)
{
// C#无法处理可选参数
对象未命中= Type.Missing;
//转到google.com
axWebBrowser1.Navigate(
" http://www.google当浏览器加载完页面时调用。
private void axWebBrowser1_DocumentComplete(.com",ref miss,ref miss,ref miss,ref miss);
//
对象发送者,AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
//
//获取对HTML文档的引用
mshtml.HTMLDocumentClass doc =
(mshtml.HTMLDocumentClass)axWebBrowser1.Document;
// HTML文档中的foreach链接
foreach(doc中的mshtml.HTMLAnchorElementClass链接)。链接)
{
if(link.href ==" http://www.google.de/grphp?hl = de& tab = wg")
//执行Google-Groups-Link上的点击
link.click();
}
}
干杯
Arne Janning
Hi Nicolas,
//add a reference to the MSHTML Object Library
[...]
public Form1()
{
InitializeComponent();
// Wait until the document has finished loading
axWebBrowser1.DocumentComplete +=
new AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent Handler(
axWebBrowser1_DocumentComplete);
}
private void button1_Click(object sender, System.EventArgs e)
{
//C# cannot deal with optional params
object miss = Type.Missing;
//goto google.com
axWebBrowser1.Navigate(
"http://www.google.com", ref miss, ref miss, ref miss, ref miss);
}
//is called when the browser has finished loading the page
private void axWebBrowser1_DocumentComplete(
object sender, AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
//get a reference to the HTML-document
mshtml.HTMLDocumentClass doc =
(mshtml.HTMLDocumentClass) axWebBrowser1.Document;
//foreach link in the HTML-document
foreach (mshtml.HTMLAnchorElementClass link in doc.links)
{
if (link.href == "http://www.google.de/grphp?hl=de&tab=wg")
{
//perform the click on the Google-Groups-Link
link.click();
}
}
}
Cheers
Arne Janning
这篇关于HREF和AXwebbrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!