So this is just a small personal project that I'm working on using awesomium in .net. So in awesomium I have this browser open and all that and I want to click this button that has this code.
<a class="buttonright" > Bump </a>
But considering it's a class and not a button I'm having trouble finding a way to "click" it. My plan is to use javascript in awesomium to click it but maybe I'm approaching this from the wrong direction?
Thanks
Depending on how you want to handle the event, there are numerous roads you can take.
The simplest one is this :
whereas if you were using a framework like jQuery, you could do it like this:
Update:
After a lot of comments (back and forth) I set up a fiddle, with a working version of this code (the code here works, too, but needed some debugging). The
eventTrigger
function in the fiddle has been stripped of all comments, but I've added an example usage of this function, which is generously sprinkled with comments.Browse through it, fork it, play around and get familiar with the code and concepts used there. Have fun:
Here's the fiddle
If by "finding a way to click it" you mean: how to programmatically click this anchor element, then this is what you can use:
Here's a X-browser, slightly verbose yet comprehensive approach:
In your case, you can use this function by querying the DOM for that particular element, like so:
That should have the effect of clicking the anchor element
If you're looking for a way to handle click events on this element (an anchor that has a
buttonright
class), then a simple event listener is all you need:That's the cleanest way to do things (one event listener handles all click events). Of course, you can bind the handler to specific elements, too: