/// <summary> /// Evaluates the expression and returns the value. /// </summary> /// <param name="webView"></param> /// <param name="expression"></param> /// <returns></returns> public string EvaluateScript(BaseWebView webView, string expression) { latch = new CountDownLatch(1); string code = "javascript:window." + Name + ".setValue((function(){try{return " + expression + "+\"\";}catch(js_eval_err){console.log('js_eval_err : ' + js_eval_err); return '';}})());"; webView.LoadUrl(code); try { // Set a 1 second timeout in case there's an error latch.Await(1, TimeUnit.Seconds); return returnValue; } catch (System.Exception ex) { DLogger.WriteLog(ex); } return null; }
/// <summary> /// Evaluates the expression and returns the value. /// </summary> /// <param name="webView"></param> /// <param name="expression"></param> /// <returns></returns> public string EvaluateScript(BaseWebView webView, string expression) { latch = new CountDownLatch(1); string code = "javascript:window." + Name + ".setValue((function(){try{return " + expression + "+\"\";}catch(js_eval_err){console.log('js_eval_err : ' + js_eval_err); return '';}})());"; webView.LoadUrl(code); try { // Set a 1 second timeout in case there's an error latch.Await(1, TimeUnit.Seconds); return(returnValue); } catch (System.Exception ex) { DLogger.WriteLog(ex); } return(null); }