- 帖子
- 37
- 主題
- 11
- 精華
- 0
- 積分
- 87
- 點名
- 0
- 作業系統
- window7
- 軟體版本
- office 2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2011-3-14
- 最後登錄
- 2022-5-30
|
[發問] 開啟 web link ,用 OnMouseDown 或其他方法
請各位高手大大幫忙如下:
用 VBA開啟一網頁後然後要點擊其 中一個link,先利用getelementsbytagname("a")取得所要的位置後,用. click開啟卻沒有動作(正常的話都會開啟),檢查HTML code發現其<a> 的 href code跟正常的不太一樣如下,也多一個 onmousedown 的event:
<a onmousedown="this.href=linkTo('/e/後面不方便列出')" href="about:" target="_blank"> ---抱歉不方便貼出原始code
google一下,有發現類似問題與解法:
-------------------------------------------------------------------
問題:
HTML Code:
<table id="table2" onmousedown="PressIt("Section2")" class="contextarea" border="0" cellspacing="0" cellpadding="0" style="height: 95px; width: 100%">
At first I thought this might be handled by using InvokeMember("click"), but that has no effect. If I try InvokeMember("onmousedown") I receive a javascript error on the page. Can anyone tell me if/how one invokes the onmousedown property of an object inside of the WebBrowser control?
As an FYI: I'm designing in 2008 and targeting .Net 2.0
解法:
WebBrowser1.Document.All("table2").RaiseEvent("OnMouseDown")
--------------------------------------------------------------------------------
似乎是利用觸動 " OnMouseDown" event來開啟。
不太清楚RaiseEvent語法該怎麼寫,試了以下code都沒用
Set wall = ifm.getElementsByTagName("a")
For Each w In wall
w.RaiseEvent("OnMouseDown") ---沒動作
'w.OnMouseDown ---沒動作
'w.OnMouseDown ---沒動作
Next
請問用VBA該如何觸動OnMouseDown event 或有其他方式可以開啟以下link
<a onmousedown="this.href=linkTo('/e/後面不方便列出')" href="about:" target="_blank"> ---抱歉不方便貼出原始code
勒勒長,感謝幫忙~~ |
|