Winform中调用js函数

            var wb = new WebBrowser();
            wb.AllowNavigation = true;
            wb.ScriptErrorsSuppressed = false;
            wb.Navigate("about:blank");
            WaitWebbrowser(wb);
            wb.Document.Write("<script>function urlEncode(url){ return encodeURIComponent(encodeURI(url)); }</script>");
            MessageBox.Show(wb.Document.InvokeScript("urlEncode", new object[] { @"http://wwww.baidu.com/音乐" }).ToString());
            wb.Dispose();
        void WaitWebbrowser(WebBrowser wb)
        { 
            while(wb.IsBusy ||(wb.ReadyState != WebBrowserReadyState.Complete && wb.ReadyState != WebBrowserReadyState.Interactive ))
                Application.DoEvents();
        }
原文地址:https://www.cnblogs.com/nanfei/p/4748082.html