function main1() {
return 1 + 1;
}
function main2(n) {
return 40968 + n;
}
function main3(n) {
return n * 5;
}
function main4(n) {
return (n + 1) * 5;
}
function main5(n) {
n = n = 4;
n = n - 2;
return (n + 1) * 5 - (n - 1);
}
/// <summary>
/// 直接调用JS方法并获取返回的值
/// </summary>
/// <param name="strJs">要执行的JS代码</param>
/// <param name="main">要调用的方法名</param>
/// <returns>执行结果</returns>
internal static string JavaScriptEval(string strJs, string main)
{
//Type
object obj = GetScriptControl();
//设置JS代码
SetScriptControlType(strJs, obj);
//执行JS
return type.InvokeMember("Eval", BindingFlags.InvokeMethod, null, obj, new object[] { main }).ToString();
}
str="上段JS内容";
JavaScriptEval(str,"main2(10)")
40978
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |