已得到IHTMLDocument2,HTML部分代码如下:
<DIV style="WIDTH: 1140px; HEIGHT: 600px">
<SPAN title=小学 onclick=go(this,this.title)>第一点</SPAN>
<SPAN onclick=start();>重点</SPAN>
<SPAN title=中学 onclick=go(this,this.title)>第二点</SPAN>
<SPAN title=高中 onclick=go(this,this.title)>第三点</SPAN>
<SPAN title=职高 onclick=go(this,this.title)>第四点</SPAN>
</DIV>希望能得到其中每一个<SPAN>,并实现点击。我使用
element  =  (IHTMLElement)doc2.all.item(8,null);  得到的情况是
<SPAN  title=小学  onclick=go(this,this.title)>第一点</SPAN>  
<SPAN  onclick=start();>重点</SPAN>  
<SPAN  title=中学  onclick=go(this,this.title)>第二点</SPAN>  
<SPAN  title=高中  onclick=go(this,this.title)>第三点</SPAN>  
<SPAN  title=职高  onclick=go(this,this.title)>第四点</SPAN>  
element  =  (IHTMLElement)doc2.all.item(9,null);  以后则得到
“第一点”等三个字
得不到我想要的<SPAN  title=小学  onclick=go(this,this.title)>第一点</SPAN> ,也就自然不能够用element.click();请大侠指教,万分感谢!!!

解决方案 »

  1.   

    call
    yourDoc->getElementsByTagName(bstrName,&pElemCollFrame);
    pElemCollFrame->click()
      

  2.   

    谢谢hdt(倦怠)指点,原来要在IHTMLDocument3中使用getElementsByTagName,但对简单的网页分析还行,有些复杂的网页分析出来不如人意,我这是其中一个DIV的内容,该网页上有多个DIV,并且内容相似,想把每个DIV放入一个IHTMLDocument2中,然后得到其中元素,不知该如何做。当然也可以得到全部元素,在想其它办法分开,但对于写C程序的人总感觉结构不流畅。
      

  3.   

    TO jiangsheng(蒋晟.Net[MVP]):
          谢谢!如您所说,可谓是一言惊醒梦中人。用execscript程序结构是最清楚的。
      

  4.   

    TO jiangsheng(蒋晟.Net[MVP]):
           但在实际使用时,有些语句有问题,比如
    onclick="send('20070903');return false;"
    会报告说当前脚本发生错误,
    'return'语句在函数之外;
    意思也很好理解,但人家就是这么用的,不知道为什么,能解释一下吗?
      

  5.   

    simulateClick
    http://developer.mozilla.org/samples/domref/dispatchEvent.html