Example #1
0
 /// <summary>
 /// 调用页面js方法
 /// </summary>
 /// <param name="funcName">函数名</param>
 /// <param name="obj">参数列表</param>
 /// <returns>返回值</returns>
 public string InvokeScript(string funcName, object[] obj)
 {
     try
     {
         string      func = JointMethodStr(funcName, obj);
         ThreadQueue tq   = new ThreadQueue(
             new Task <Task <JavascriptResponse> >(funcEval => {
             return(WebBrowser.EvaluateScriptAsync(funcEval.ToString()));
         }, func), this);
         tq.Start();
         tq.Wait();
         if (null != tq.Result)
         {
             if (null != tq.Result.Result)
             {
                 if (null != tq.Result.Result.Result)
                 {
                     return(tq.Result.Result.Result.ToString());
                 }
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #2
0
 public string InvokeScript(string funcName, bool isEval = false)
 {
     try
     {
         if (!isEval)
         {
             funcName = JointMethodStr(funcName, null);
         }
         ThreadQueue tq = new ThreadQueue(
             new Task <Task <JavascriptResponse> >(funcEval => {
             return(WebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(funcEval.ToString()));
         }, funcName), this);
         tq.Start();
         tq.Wait();
         if (null != tq.Result)
         {
             if (null != tq.Result.Result)
             {
                 if (null != tq.Result.Result.Result)
                 {
                     return(tq.Result.Result.Result.ToString());
                 }
             }
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }