In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
今天就跟大家聊聊有关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互调实验传参和返回值异常的示例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.