Blue
Red
Green
Orange
Voilet
Slate
Dark

(高分)怎么让鼠标点IE窗口里面的连接?(200分)

Q

qfgj

Unregistered / Unconfirmed
GUEST, unregistred user!
点文本连接
 
A

andy263

Unregistered / Unconfirmed
GUEST, unregistred user!
用Twebrowser写个程序代替ie
 
Q

qfgj

Unregistered / Unconfirmed
GUEST, unregistred user!
使用什么属性找我要的连接?有很多个连接.<br>还有用什么方法让鼠标点找到的连接?
 
Q

qfgj

Unregistered / Unconfirmed
GUEST, unregistred user!
老大说清楚一点,Twebrowser我不太会用
 
A

andy263

Unregistered / Unconfirmed
GUEST, unregistred user!
窗体上放一个TwebBrowser控件<br><br>uses MSHTM;<br>procedure TForm1.Button1Click(Sender: TObject);<br><br>var<br>&nbsp; doc: IHTMLDocument2;<br>&nbsp; all: IHTMLElementCollection;<br>&nbsp; len, i, flag: integer;<br>&nbsp; item: IHTMLElement;<br>&nbsp; vAttri: Variant;<br>begin<br><br>&nbsp; &nbsp; //获得Webbrowser对象中的文档对象<br>&nbsp; doc := WebBrowser1.document as ihtmldocument2;<br>&nbsp; &nbsp; //获得文档中所有的HTML元素集合<br>&nbsp; all := doc.get_all;<br>&nbsp; len := all.get_length;<br>&nbsp; &nbsp; //访问HTML元素集合中的每一个元素<br>&nbsp; for i := 0 to len - 1 do<br>&nbsp; begin<br>&nbsp; &nbsp; item := all.item(i, varempty) as IHTMLElement;<br>&nbsp; &nbsp; &nbsp; //如果该元素是一个链接<br>&nbsp; &nbsp; if item.Get_tagname = 'A' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; flag := 0;<br>&nbsp; &nbsp; &nbsp; vAttri := item.getAttribute('protocol', flag); //获得链接属性<br>&nbsp; &nbsp; &nbsp; if vAttri = 'http:' then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; vAttri := item.getAttribute('href', flag);<br>&nbsp; &nbsp; &nbsp; &nbsp; if pos('http://www.delphibbs.com', vAttri) &gt; 0 then //如果链接中包含大富翁的地址<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WebBrowser1.Navigate(vAttri );//点击这个链接<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;
 
Q

qfgj

Unregistered / Unconfirmed
GUEST, unregistred user!
谢谢,不过MSHTM单元找不到啊
 
Q

qfgj

Unregistered / Unconfirmed
GUEST, unregistred user!
这样写有什么问题?<br>procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;<br>&nbsp; const pDisp: IDispatch; var URL: OleVariant);<br>var<br>&nbsp;oDoc: OleVariant;<br>&nbsp;oItem: OleVariant;<br>&nbsp;I: Integer;<br>&nbsp;vAttri:variant;<br>begin<br>&nbsp;oDoc := (Sender as TWebBrowser).Document;<br>&nbsp;for I := 0 to oDoc.All.Length - 1 do begin<br>&nbsp; &nbsp;oItem := oDoc.All.Item(I);<br>&nbsp; &nbsp;if oItem.tagName = 'A' then begin<br>&nbsp; &nbsp; &nbsp;vAttri := oitem.getAttribute('protocol', 0); //获得链接属性<br>&nbsp; &nbsp; &nbsp;if vAttri = 'http:' then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;vAttri := item.getAttribute('href', 0);<br>&nbsp; &nbsp; &nbsp; &nbsp;if pos('http://www.delphibbs.com', vAttri) &gt; 0 then //如果链接中包含大富翁的地址<br>&nbsp; &nbsp; &nbsp; &nbsp; WebBrowser1.Navigate(vAttri );//点击这个链接<br>&nbsp; &nbsp; &nbsp; &nbsp;break;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp;end;<br>&nbsp;end;<br>end;
 
L

liaoshu

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp;oDoc := (Sender as TWebBrowser).Document;<br><br>&nbsp; for I := 0 to oDoc.All.Length - 1 do begin<br>&nbsp; &nbsp; oItem := oDoc.All.Item(I);<br>&nbsp; &nbsp; if oItem.tagName = 'A' then begin<br>&nbsp; &nbsp; &nbsp; vAttri := oitem.getAttribute('protocol', 0); //获得链接属性<br>&nbsp; &nbsp; &nbsp; if vAttri = 'http:' then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; vAttri := oitem.getAttribute('href', 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; if pos(('http://www.delphibbs.com', vAttri), vAttri) &gt; 0 then //如果链接中包含地址<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oitem.click;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>&nbsp; end;
 
Q

qfgj

Unregistered / Unconfirmed
GUEST, unregistred user!
多人接受答案了。
 

Similar threads

S
回复
0
查看
745
SUNSTONE的Delphi笔记
S
S
回复
0
查看
625
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
970
SUNSTONE的Delphi笔记
S
顶部 底部