网站源码中是window.clk=function(b,c,d,e,f,g,h){if(document.images){var a=encodeURIComponent||escape;(new Image).src=["/url?sa=T\x26source\x3dweb",c?"&oi="+a(c):"",d?"&cad="+a(d):"","&ct=",a(e||"res"),"&cd=",a(f),b?"&url="+a(b.replace(/#.*/,"")).replace(/\+/g,"%2B"):"","&ei=","",g].join("")}return true};
<a href="http://www.test.com" target=_blank class=l onmousedown="return clk(0,'','','res','1','')">test</a>用javascript模拟鼠标点击
if (document.URL.indexOf("aaa.com") != -1)
{
var obj = document.getElementsByTagName("a");
for (var i=0;i<obj.length;i++)
{
if(obj[i].href.indexOf("http://www.bbbb.com") != -1)
{
                                obj[i].onmousedown();
window.open(obj[i].href, "adWindow");
foundAd = true;
break;
}

}
}
obj[i].onmousedown();
这个来模拟 clk函数 好像不行啊 不知道错误在哪里?

解决方案 »

  1.   

    你要点击哪个控件.
    直接document.getElementById('id').click()就行了...
      

  2.   

    document.getElementById('id').click()就行了...
      

  3.   

    document.getElementById('id').click() 可以打开连接 但是好像无法 触发onmousedown 事件
      

  4.   

    obj[i].onmousedown(); ,我试过了,这个可以触发鼠标的按下时间,不过用楼主上面写的东西来试验,js语句根本就没有走近if语句,也就是根本就没执行到这句obj[i].onmousedown(); 触发事件的语句
      

  5.   

    Firefox下不行。请问哪位知道Firefox下如何模拟鼠标点击?