是这样的,最近一直在玩一个网页游戏,叫武林三国,想做个自动建造建筑的功能的软件,就是类似自动模拟在网页里面操作用的webbrowser,一般的网页还好,但他是Ajax、Javascript的网页没办法像以前一样用webbrowser1.Document.getElementById("username").Value = usr.Text
webbrowser1.Document.All("logfrm").submit这些代码发送数据页面大致是这样的,进去是main.php,然后点了某建筑后,页面用了Javascript技术在直接页面当中(未更改URL),弹出来一个框,在框内打开相关的build.php,并点里面的按扭完成操作那个按扭的代码是这样的
<a href="javascript:;" onclick="upgradeStart(7, this); return false;" class="CBU">建造</a>我分析了下,他那个7代表当前建筑的ID,其他的都不知道
实在无从下手,常识了很多方法,都不行,也请高手能教教我,用什么方法,最好能有部分代码,我用的VB 6.0

解决方案 »

  1.   

    用MSHTML拦截一下网页事件,找出你需要的事件,分析它的URL就可以了。
      

  2.   

    网页用的JS,相关代码是:function upgradeStart(A,B){B.remove();sj.queryData.pid=A;sj.sendRequest()}var logic={ajaxId:"jz",act:"build_building",type:"e"};var ctl=[];var jz=new DAjax("/modules/build/build_building.php",{option:{method:"get"},logic:logic});jz.onComplete=function(){get_city_building.sendRequest();set_city_resource.sendRequest();if("city_build_resource"==currentTabId||"city_build_building"==currentTabId||"city_out"==currentTabId||"city_in"==currentTabId){eval(currentTabId+".sendRequest();")}if("undefined"!=typeof (this.responseData.func)){eval(this.responseData.func+"();")}else{var i=mask.processInfo(this.responseData,"o");setTimeout("mask.removeById("+i+")",1000)}window.scrollTo(0,0)};jz.onNoneGet=function(){mask.showMsgBox(this.errorMessage,true)};
      

  3.   

    现在就是不知道用什么代码给这个文件传递参数
    modules/build/build_building.php
      

  4.   

    upgradeStart(建筑的ID,要关闭的表单对象)
    因为这个是AJAX请求,你看他的JS代码中,需要一个id为sj_building_form的form表单
    你可以动态创建一个
    HtmlElement forme = docwebbrowser1.Document.CreateElement("form");
    forme.SetAttribute("id", "sj_building_form");
    forme.InnerHTML = "<a href=\"#\" onclick=\"upgradeStart(7,$(this));return fasle;\"></a>"
    docwebbrowser1.Document.Body.AppendChild(forme);
    forme.FirstChild.InvokeMember("click");
      

  5.   

    因为没在C#中调试过,上面有点问题,现在改过来upgradeStart(建筑的ID,要关闭的表单对象) 
    因为这个是AJAX请求,你看他的JS代码中,需要一个id为sj_building_form的form表单 
    你可以动态创建一个 
    HtmlElement forme = docwebbrowser1.Document.CreateElement("form"); 
    forme.SetAttribute("id", "sj_building_form"); 
    forme.InnerHtml= " <a href=\"#\" onclick=\"upgradeStart(7,$(this));return fasle;\">; </a>" 
    docwebbrowser1.Document.Body.AppendChild(forme); 
    forme.FirstChild.InvokeMember("click");