public partial class WebTest: Window { private void Window_ContentRendered(object sender, EventArgs e) { this.wbrExam.ObjectForScripting = new OprateBasic(this); this.wbrExam.Source = new Uri(Environment.CurrentDirectory + @" es emplate.html"); } public void Wtest(string str) { MessageBox.Show(str); } } [System.Runtime.InteropServices.ComVisible(true)] public class OprateBasic { private WebTest instance; public OprateBasic(WebTest instance) { this.instance = instance; } public void HandleTest(string p) { instance.Wtest(p); } }
js->cs:window.external.HandleTest(“测试”);
cs->js:this.wbrExam.InvokeScript("js方面名", new object[] { "hello" });