1

I'm trying to execute some piece of javascript in my awesomium WebControl wb.
An element exampleDiv shall be clicked when the user clicks on a button on my GUI.

private void button_Click(object sender, RoutedEventArgs e)
{
    if (wb.IsDocumentReady)
    {
        wb.ExecuteJavascript("document.getElementById('exampleDiv').click();");
    }
}

If I execute this piece of javascript in Chrome everything works fine.
If I execute this in awesomium nothing happens.
Simple things like alert('Hello'); works fine but I didn't get anything else to work.

I also found this article executing javascript in awesomium to click on a div but it didn't help too.

I'm using the latest awesomium build (1.7.3).

Community
  • 1
  • 1
TorbenJ
  • 4,462
  • 11
  • 47
  • 84

2 Answers2

1

I'm not certain if the issue is the version of chrome loaded with 1.7.3 or if its something else however i think what you should be doing is this:
document.getElementById('exampleDiv').onclick()

I tested something similar to your example with 1.7.3 using the attached debugger and i got the error:
TypeError: Object #<HTMLSpanElement> has no method 'click'

That span has a wired click event on it, and i can trigger it using: document.getElementById('mySpan').click() with chrome, but had to use .onclick() in awesomium.

Testing the same in the current version of chrome it works just fine. My guess is its most likely chrome 18, but I do not have the time at the moment to install it and verify.

If you are using jQuery then you could also use $('#exampleDiv').click();

b0redom
  • 387
  • 2
  • 11
0

You can simply do this

dynamic submit = document.getElementById("exampleDiv"); submit.Invoke("click");

and this piece of code will be inside webcontrol -> loadingframeComplete section. Works 100% for me.

nhasan
  • 21
  • 2
  • 7