using CefSharp; using CefSharp.WinForms; using efunbox_xyyf_windows.cusview; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace efunbox_xyyf_windows { public partial class Form1 : Form { public Form1() { InitializeComponent(); initWeb(); } private void Form1_Load(object sender, EventArgs e) { } void initWeb() { var setting = new CefSettings(); setting.Locale = "zh-CN"; CefSharp.Cef.Initialize(setting); webview.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; webview.JavascriptObjectRepository.Settings.JavascriptBindingApiEnabled = true; webview.JavascriptObjectRepository.ResolveObject += (s, eve) => { var repo = eve.ObjectRepository; //eve.ObjectName对应html里面绑定的bindName if (eve.ObjectName == "efunboxJS") { repo.Register("efunboxJS", new JSInterfaces(), isAsync: true, options: BindingOptions.DefaultBinder); } // else if (eve.ObjectName == "videoJS") // { // repo.Register("videoJS", new VideoJs(), isAsync: true, options: BindingOptions.DefaultBinder); // } }; String url = "http://m-xyyf-web.ai160.com/stage/index/index.html?"; StringBuilder paramss = new StringBuilder(); paramss.Append("uuid=02b5c3ec-4be9-3337-bc0a-f4a172b0f0c8"); paramss.Append("&"); paramss.Append("appCode=2006"); url= url+paramss.ToString(); webview.LoadUrl(url); webview.MenuHandler = new MenuHandler(); webview.DragHandler=new DragHandler(); } private void Form1_Resize(object sender, EventArgs e) { webview.Dock = DockStyle.Fill; } private void button1_Click(object sender, EventArgs e) { System.Diagnostics.Debug.WriteLine("xxxxxxx"); } } }