Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of abnormal parameters and return values in the experiment of Intermodulation between c # and js in WebKit.Net winform Program

Shulou Source: shulou.com Published: 2022-06-03 11:31:39 09月29日 Update

今天就跟大家聊聊有关WebKit.Net winform程序中c#与js互调实验传参和返回值异常的示例分析,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

currentPage.browser.IsScriptingEnabled = true; //currentPage.browser.StringByEvaluatingJavaScriptFromString("var _elm = document.getElementById('testelement');var _evt = document.createEvent('MouseEvents');_evt.initEvent('click', true, true);_elm.dispatchEvent(_evt);"); Console.WriteLine("888888888888888888888"); Console.WriteLine("currentPage.browser.DocumentText=" + currentPage.browser.DocumentText); //currentPage.browser.StringByEvaluatingJavaScriptFromString("document.getElementById('testelement').click()"); //currentPage.browser.Document.InvokeScriptMethod("test",new object[]{"name","address"});//出异常,不能这样调用,要如下面这样调用 //currentPage.browser.StringByEvaluatingJavaScriptFromString("f()"); //string returnvalue = (string)currentPage.browser.Document.InvokeScriptMethod("f"); //Console.WriteLine("returnvalue=" + returnvalue); //currentPage.browser.Document.InvokeScriptMethod("test", new object[] { "name", "address" }); //string msg = currentPage.browser.StringByEvaluatingJavaScriptFromString("function GetElement() {return document.getElementsByTagName(\"testelement\")[0].outerHTML};"); //currentPage.browser.Invoke((MethodInvoker)delegate { currentPage.browser.Document.InvokeScriptMethod("GetElement"); }); object msg = currentPage.browser.Document.InvokeScriptMethod("GetElement"); Console.WriteLine("msg=" + msg); TitleHello, World!

A

B

C

hello world spring boot3111 window.alert("Name is " + name + "; address is " + address); function GetElement() { return document.getElementsByTagName("testid")[0].outerHTML};function f() { document.title="abc";window.open('https://www.baidu.com', 'myWindow'); }function test(name, address) { document.title=name;} function GetElement() {return document.getElementsByTagName('testelement')[0].innerText}; test1 test2 innerHTML内容innerText内容outerHTML内容

wbkit.net实验发现:不管是c#给js函数传什么参数或者说js函数给c#返回什么值,总是异常。只有c#单纯调用js中函数且函数名不带括号才能成功。

看完上述内容,你们对WebKit.Net winform程序中c#与js互调实验传参和返回值异常的示例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。

Tags: Content caching functions experiments examples programs analysis success parameters only parentheses more knowledge articles industry information information channels channels enter one support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno MariaDB macOS vpn