快速上手

js和C#互相调用。

C#调用js比较容易。JS调用C#代码,现有两种方法。老方法的缺点是只支持单页,如果切换页面,原有创建的变量就失效了。新方法没有这些问题。

老方法:

Cefsharp js调用c#与c#调用js

CefSharp 与 js 相互调用

新方法

https://github.com/cefsharp/CefSharp/issues/2246

  var options = new CefSharp.BindingOptions() {CamelCaseJavascriptNames = false};
var bindingOptions = options; //For async object registration (equivalent to RegisterJsObject)
this.Browser.JavascriptObjectRepository.Register("boundAsync", new BoundObject(), true, options);
this.Browser.JavascriptObjectRepository.Register("boundAsync2", new AsyncBoundObject(), true, options);
<script type="text/javascript">
function aa()
{
// <embed user provided code here>
CefSharp.BindObjectAsync("boundAsync", "bound").then(function (result) {
boundAsync.hello('CefSharp');
}); };
function bb(){
CefSharp.BindObjectAsync("boundAsync2").then(function(result)
{
boundAsync2.hello('CefSharp');
});
} </script>

demo1

参考链接:

快速开始

https://github.com/cefsharp/CefSharp/wiki/Quick-Start

wpf中使用

https://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part

官方demo

https://github.com/cefsharp/CefSharp.MinimalExample

博客园博客

https://www.cnblogs.com/M-Silencer/p/5846494.html

最新文章

  1. 性能优化九之UI卡顿分析
  2. winform程序自动升级
  3. jquery/js实现验证聚焦,失焦
  4. 提高Web页面性能的技巧
  5. android之硬件访问服务框架
  6. JNI 多线程
  7. Apache无法启动解决方案
  8. iOS开发之第三方登录QQ -- 史上最全最新第三方登录QQ方式实现
  9. 新服务器sudo与权限分配&lt;NIOT&gt;
  10. ArrayList类
  11. Unity使用Mono.Xml代替System.Xml 测试
  12. The JRE_HOME environment variable is not defined correctly
  13. 把一个List拆分为几个大小一样的List
  14. dojo:如何为表格添加从数据库获得存储的下拉框
  15. 图片路径中含有中文在jsp下不能正常显示的问题
  16. c# 策略模式 加工厂模式-对象与行为分离
  17. Hadoop源码阅读-HDFS-day2
  18. Scala + Thrift+ Zookeeper+Flume+Kafka配置笔记
  19. JQuery this和$(this)的区别
  20. javascript实现数据结构: 树和森林

热门文章

  1. 如何从jks文件中导出公私钥
  2. python r r+ w w+ rb 文件打开模式的区别
  3. oracle的常用99条语句
  4. 697. Degree of an Array
  5. 2018.11.06 bzoj1835: [ZJOI2010]base 基站选址(线段树优化dp)
  6. Linux下启动tomcat报错RROR org.apache.catalina.core.StandardContext- Error starting static Resources java.lang.IllegalArgumentException: Document base /home/duiba/apache-tomcat/webapps/../webapps/manager do
  7. IntellJ IDEA2017 springboot2.0.2中读取配置
  8. poj 1125 Stockbroker Grapevine(最短路径)
  9. Ng第十五课:异常检测(Anomaly Detection)
  10. (转)ASP.NET MVC 3和Razor中的@helper 语法