WinForms WebBrowser控件 - 在AJAX之后获取文档元素?

时间:2010-02-01 21:09:34

标签: c# javascript .net ajax webbrowser-control

我在C#中使用来自Windows Forms的WebControl,我正在尝试加载Web Ajax内容(我认为内容是ajax)这是从资源管理器中检索的页面代码:

<ul id="building">
   <li id="button1" class="on">
    <div class="supply1">
     <div class="buildingimg">
      <a class="fastBuild tips" title="|Expandir Mina de metal al nivel 11" href="index.php?page=resources&session=ccec6b62991a&modus=1&type=1&menge=1&token=ae485059d2eb1d87bc6f181744a4b4ab">
       <img src="img/layout/sofort_bauen.gif" width="22" height="14" />
      </a><a class="detail_button tips slideIn" title="|Mina de metal" ref="1" id="details"
       href="#"><span class="ecke"><span class="level"><span class="textlabel">Mina de metal
       </span>10 </span></span></a>
     </div>
    </div>
   </li>

按下图像时,新的面板加载而不重新加载整个页面。

如何模拟点击图片以加载面板?

在本页的其他控件中,我使用myWebBrowser.Document.RaiseEvent(“”)方法来模拟点击,但在这种情况下没有任何onclick事件...我不明白如何启动面板的加载。

在页面底部是一些javascript方法(我没有把所有脚本都放大,因为很大)

PD:对不起我的英语,我正在研究它。感谢。

我正在重新阅读代码并查看此代码:

function loadDetails(type)
{
    $.post(
        "index.php?page=resources&session=ccec6b62991a&ajax=1",
        { type: type},
        function(data){
            $("#detail").html(data);
            $("#techDetailLoading").hide();
            $("input[type='text']:first", document.forms["form"]).focus();

            reloadCluetip();
        }
    );
}

它与我的问题有关系吗?

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

Mythox, 我试图在同一页面上做同样的事情,实际上当对话框完美打开时,在4个10个以上的情况下,我也能够开始新对话框打开所需的构造。 问题是我的方法不是100%的故障安全,但可以肯定它是达到解决方案的一种方法。 我在这里发布了代码。

     HtmlDocument doc = Program.BrowsingSystem.Document;
            HtmlElement ele = doc.GetElementById("button3");
            if (!ConstructionButtonIsAllowedToBePressed(ele))
                return new ActionResponse(false);
            if (ele.GetAttribute("classname").ToLower().Contains("disabled")) //the unit is disabled due to missing resources or other activities running
            {
                return new ActionResponse(false);
            }
            if (ele.GetAttribute("classname").ToLower().Contains("off")) //the unit is unreacheble at this planet level
            {
                return new ActionResponse(false);
            }

            ele = ele.FirstChild.FirstChild.FirstChild.NextSibling;

            object obj = ele.DomElement;
            System.Reflection.MethodInfo mi = obj.GetType().GetMethod("click");
            mi.Invoke(obj, new object[0]);


            semaphoreForDocCompletedEvent = WaitForDocumentCompleted(genWaitingTimeForNonEventingActions*2);

            ele = doc.GetElementById("planet");

            ele = ele.FirstChild.NextSibling.NextSibling;

            obj = ele.DomElement;
            mi = obj.GetType().GetMethod("submit");
            mi.Invoke(obj, new object[0]);

            semaphoreForDocCompletedEvent = WaitForDocumentCompleted(genWaitingTimeForNonEventingActions);
            if (!semaphoreForDocCompletedEvent)
                return new ActionResponse(false);
相关问题