The C# webbrowser and Widgets
-
Hi, I'm using the C# webbrowser in order to automate the navigating to a web site, the website is using widgets whichs means a terrible javascript code behind.. For example, a TR that opens a new Tab, looks like this: "" And I want to say to C# to click this TR in order to open the tab, which means invoking the MU_function(event,this) or maybe MO_function(event,this)then MU_function(event,this). There's a way of communication between C# and Javascript: by doing something like :
MyWebBrowser.Document.InvokeScript("alert", new string[] { "Hello World" });
by using System.Diagnostics namespace and doing : [ComVisible(true)] public partial class MainForm : Form .... This InvokeScript can also execute a javascript function in the page, so there's a possibility to invoke the MU_function(event,this).. (event: mouseup, this: the TR tag). Now the problem is: (event,this) have to be JavaScript objects!! How can we do this?? I was thinking for a while, I got an idea: what if we serialize the "event" which is a MouseEvent object and the "this" which is a HTMLElement, then deserializing them to 2 assembly types or whatever, in this case the code should looks like : MyWebBrowser.Document.InvokeScript("MU_function", new object[] { ObjEvent , Objthis }); Do you know how can we serialize to javascript object ??? I tried the XML one but I don't know how to make them in the function pamaretres!!!