Thursday 15 July 2010

Executing javascript containing method in WebBrowser control C# -


I need some help in executing this part of the JavaScript code in webbrowser control on the website, executing it like this are:

  "javascript: timeout ( '__ doPostBack (\' dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e1_6bse0453e306 $ ba400 $ rd processing $ ucTopQuestions $ qst_1995 \ ', \' \ ') , 0) "  

I have tried many things, something like:

  webBrowser1.Navigate (" javascript: setTimeout ( '__ doPostBack (\ 'Dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e 1_6bse0453e306 $ ba400 $ rd processing $ ucToQuestions $ qst_1995 \ ',' '' '', 0) ");  > Also try:  
  HTMLElement head = webBrowser1.Document.GetElementsByTagName ("head") [0]; HtmlElement script AL = web browser 1 Document. Crate Element ("script"); IHTMLScriptElement element = (IHTMLScriptElement) scriptEl.DomElement; Element.text = "Function __doPostBack (eventTarget, eventArgument)"; Head.AppendChild (scriptEl); Webbroser1.Document.InvokeScript ( "__ doPostBack (\ 'dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e1_6bse0453e306 $ ba400 $ rdProcess $ ucTopQuestions $ qst_1995 \', \ '\'");   

I j S exception:

Enter image details here

EDIT2:

I also have:

  string bit = @ "function __do postback (Iventtag, Iventargment) {if (! Theform. onsubmit || (theform.onsubmit ()! = false)) {theForm .__ EVENTTARGET.value = eventTarget; the form .__ EVENTARGUMENT.value = eventArgument; theForm.submit ();}} "; element.text = s; Also tried    
  webBrowser1.Document.InvokeScript (@ "__ doPostBack (\ "\") 'Dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e1_6bse0453e306 $ ba400 $ rdProcess $ ucTop Prsnan $ qst_1995 \', \ '\' ")   

But nothing happens The browser should refresh. Here is the code from the browser:

  & lt; Select name = "dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e1_6bse0453e306 $ ba400 $ rdProcess $ ucTopQuestions $ qst_1995" onchange = "javascript: setTimeout ( '__ doPostBack (\' dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e1_6bse0453e306 $ ba400 $ rdProcess $ ucTopQuestions $ qst_1995 \ ' , \ '\'), 0) "id =" dsl50 $ ct160 $ ​​g_818f5662_1255_51ab_d4e1_6bse0453e306 $ ba400 $ rdProcess $ ucTopQuestions $ qst_1995 "class =" dropdown "pid =" as2ba2d5-d2cc-dad2-9e35-abd345678aac "& gt; ; & Lt; Option value = "1 (1)" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2 (2)" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3 (3)" & gt; 3 & lt; / Options & gt; & Lt; / Select & gt;    

Check this link:

Code:

  HTMLElement head = webBrowser1.Document.GetElementsByTagName ("head") [0]; HtmlElement script AL = web browser 1 Document. Crate Element ("script"); IHTMLScriptElement element = (IHTMLScriptElement) scriptEl.DomElement; Element.text = "say hello (function) {alert ('hello'}}" Head.AppendChild (scriptEl); WebBrowser1.Document.InvokeScript ("sayHello");    

No comments:

Post a Comment