后台调用前台带参数的JS函数?

string html = PrintTable(printvalue);
Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", @"PrintView('" + html + "');", true);
<script language="javascript" type="text/javascript">
var LODOP; //声明为全局变量
function PrintView(htmlHead) {
LODOP = getLodop();
LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_表单一");
LODOP.SET_PRINT_STYLE("FontSize", 18);
LODOP.SET_PRINT_STYLE("Bold", 1);
LODOP.ADD_PRINT_HTM(40, 18, "97%", 200, htmlHead);
LODOP.PREVIEW();
};
</script> 
这样写不对。老是报错,谁能教我一下

汪汪一只猫
浏览 652回答 2
2回答

繁花如伊

ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");Compilable compilable = (Compilable) engine;Bindings bindings = engine.createBindings(); // Local级别的BindingString script = "var c; function add(op1,op2){ c=1; return c+op1+op2} add(a, b)"; // // 定义函数并调用CompiledScript JSFunction = compilable.compile(script); // 解析编译脚本函数bindings.put("a", 1);bindings.put("b", 2);// 通过Bindings加入参数Object result = JSFunction.eval(bindings);System.out.println(result); // 调用缓存着的脚本函数对象,Bindings作为参数容器传入out.print(result);
打开App,查看更多内容
随时随地看视频慕课网APP