简体   繁体   English

在C#WebBrowser控件中触发JavaScript

[英]Firing JavaScript inside a C# WebBrowser Control

Trying to write an app that searches a WebBrowser control in C# and get the elements of a flash page. 尝试编写一个使用C#搜索WebBrowser控件并获取Flash页面元素的应用。 Problem is with Flash you don't have access to all of the DOM objects and if Firebug I get something like: 问题出在Flash上​​,您无法访问所有DOM对象,如果Firebug出现类似问题:

<div>
  <div class="nvbar_start"></div>
  <div class="nvbar_middle">
    <a **onclick="ajaxLinkSend('globalContainer', 'quests.php');** return false;" href="javascript:;">
      <span class="hover_header">Quests</span>
    </a>
  </div>
  <div class="nvbar_end"></div>
</div>

Thus I cannot fire the OnClick event... Tried researching and I know it the answer is here but evidently I'm asking the wrong question. 因此,我无法触发OnClick事件...经过研究,我知道答案就在这里,但显然我在问一个错误的问题。 Can anybody point me in the right direction? 有人能指出我正确的方向吗?

Thanks Wayne 谢谢韦恩

If you can trigger the event with javascript then in the WebBrowser Control you can wb.Navigate("Javascript:DoFoo();"); 如果可以使用javascript触发事件,则可以在WebBrowser控件中wb.Navigate("Javascript:DoFoo();");

Use a browser console window to figure out the necessary javascript for this (if it is even possible in your context). 使用浏览器控制台窗口找出为此所需的JavaScript(如果在您的上下文中甚至可能的话)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM