Private void Form1_Load (object sender, EventArgs e) { @ "\i.html"); = webbrowser1.documenttext; }
Private voidButton2_Click (Objectsender, EventArgs e) {WebBrowser1.Document.InvokeScript ("GetCode",New Object[] {"1567613","228267824","Top One","d7d796981b62d318"}); if(WebBrowser1.Document.GetElementById ("msg") !=NULL) {htmlelement element= WebBrowser1.Document.GetElementById ("msg"); Txtinfo.text= element. GetAttribute ("value"); } }
function GetCode (Lbdid, ldocid, text, SessionID) { document.getElementById ("MSG"). Value = H2 (Lbdid + '-' + ldocid + ') -' + P (text), +, SessionID);}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en"><HTML> <Head> <title></title><Scripttype= "Text/javascript"src= "I.js"></Script> </Head> <Body> <inputtype=textID=msg/> </Body></HTML>
Use an HTML page as the medium to pass the returned value to the control in the HTML, and then in WebBrowser
HtmlElement element = WebBrowser1.Document.GetElementById ("msg"); Txtinfo.text = element. GetAttribute ("value")
Get value
WebBrowser executes the JS method, and returns the value, C # background value