예제 #1
0
        /**
         * JS 스크립트 실행
         * @param jsString
         * @param document
         */
        public void ExecuteJS(String jsString, CefSharp.IFrame document)
        {
            this.webBrowser.Invoke(new Action(() =>
            {
                String command = String.Format(@"
                    (function() {{
                        window.requestAnimationFrame(function() {{
                            {0}
                        }});
                    }})
                ", jsString);

                String script = String.Format(@"(function() {{ 
                            if (document.readyState != 'loading') {{
                                {0}();
                            }} else if (document.addEventListener) {{
                                document.addEventListener('DOMContentLoaded', {0});
                            }} else {{
                                document.attachEvent('onreadystatechange', function() {{
                                  if (document.readyState != 'loading')
                                    {0}();
                                }});
                            }}
                        }})()", command);

                //JavascriptResponse resutls = await document.EvaluateScriptAsync(script);
                document.ExecuteJavaScriptAsync(script);
            }));
        }
예제 #2
0
 public void RunCode(string code)
 {
     if (parent != null)
     {
         parent.ExecuteJavaScriptAsync(code);
     }
 }