Export to GitHub

open-webkit-sharp - issue #11

implement a click event for webkit browser


Posted on Oct 11, 2011 by Helpful Bird

What steps will reproduce the problem? 1. how to implement a click event in a webkit browser. 2. for example, if google page is displayed in the webkit browser and now a click on google search button to be implemented > 3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Comment #1

Posted on Oct 11, 2011 by Helpful Ox

WebKit doesn't provide a Click() event, just a Right Click event. I will see if I can do something and will inform you.

Comment #2

Posted on Oct 12, 2011 by Helpful Bird

thx for ur quick response. could u pls check any other alternative to provide the code thru click any button functionality. i will be eagerly waiting for ur reply. thx in advance

Comment #3

Posted on Oct 12, 2011 by Helpful Ox

I will try to implement a click event for 1.8 (or at least for 1.9)

Comment #4

Posted on Nov 19, 2011 by Swift Monkey

Hello Sir,

Firstly, thanks for launching such a great product. I am using it for my application, and it seem to be a solution to all my problems. Only issue that i faced is; if i want to click on any html tag (be it input, div, span), i couldn't find any method to do so? I was looking for something like InvokeMember available in default web browser for .Net applications.

Please tell me, if there exist any function like that, in webkit browser.

Many thanks in advance.

Comment #5

Posted on Nov 19, 2011 by Helpful Ox

If I understood what you are trying to do, it is not implemented in the latest webkit. At some elements such as Input and other HTML elements there is a method called click() but as I have sawn in the latest webkit's source it is not implemented. Maybe it will be in the future but for now something like that is not possible. If I find any "hackish" method I will inform you.

Comment #6

Posted on Apr 17, 2012 by Helpful Ox

The feature that you want can also be done using JavaScript:

document.getElementById('id').click();

You can use that using .StringByEvaluatingJavaScriptFromString

Comment #7

Posted on Jul 4, 2012 by Helpful Horse

I dont understand, how solve this problem. e.g. I have own site, it is load in webkit browser. When I click button(picture) in html page, I need to write in com port, or make sound, or something else

Comment #8

Posted on Jul 4, 2012 by Helpful Ox

OK I will reply you with an example. Let's say that the button you want has an ID attribute "myButton". So, in order to click it you can use the first way (for .NET 4) or the 2nd way (for any .NET Framework)

1st way: .GetScriptManager.EvaluateScript("document.getElementById('myButton').click();");

2nd way: .StringByEvaluatingJavaScriptFromString("document.getElementById('myButton').click();");

You can check the Id of the element via the inspector.

Comment #9

Posted on Jul 4, 2012 by Helpful Horse

Ok, but if I want to insert c# code on event: SystemSounds.Beep.Play();

where I need to post it?

Comment #10

Posted on Jul 4, 2012 by Helpful Ox

Do you mean that you want to listen to a JavaScript event and run C# code? If so, then this capability is not yet implemented in OpenWebKitSharp (yet), but you can pass an object to JS via GetScriptManager.SetProperty("myObject", new MyObject());, inside the MyObject class put a method:

void Beep() { SystemSounds.Beep.Play(); }

And instead of raising an event in JS, use myObject.Beep(); instead of the event or add a handler for that event in JS and use the above JS code.

Comment #11

Posted on Aug 17, 2012 by Happy Rhino

I have created a dynamic button in webkit browser. I need click even for that button. How can I do it.

This is how I generate button:

mBrowser.DocumentText = "" + "function test(message) { alert(message); }" + "" + "call client code from script code" + "";

Thanks in Advance.

Status: Accepted

Labels:
Type-Defect Priority-Medium