使用usemap模拟单击图像

本文关键字:图像 单击 模拟 usemap 使用 | 更新日期: 2023-09-27 18:27:42

我知道如何使用Web浏览器控件模拟按钮上的click事件。然而,我无法在具有关联mouseupmousedown事件的usemap的图像上模拟click事件。

我该怎么做?

Bellow是与图像和usemap相关联的html:

<img src="http://www.temp.com/zoom_off.gif" id="photo_zoom" style="width: 39px; height: 23px; border: 0" alt="" usemap="#btnZCMap">
 <area shape="rect" coords="2,2,19,25" href="#" onmouseover="doBtn('photo_zoom','in'); return false;" onmouseout="ZM=0; doBtn('photoe_zoom','off'); return false;" onmousedown="ZM=1; doZC(-1); return false;" onmouseup="ZM=0; return false;" onclick="return false;">

使用usemap模拟单击图像

首先,您需要获取元素,然后调用正确的成员,例如:

For Each elem As HtmlElement In webBrowser1.Document.GetElementsByTagName("img")
    If elem.GetAttribute("alt") = "MyImage" Then
        elem.InvokeMember("click")
    End If
Next

如果这不起作用,你可以尝试RaiseEvent:

WebBrowser1.document.GetElementById("ImgID").RaiseEvent("onclick")